mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Move nmspinning address lookup to dynamic facts render
This removes the need to check the offset every release. I've also removed the negative build tag from runtime_amd64.go, which less obviously correct. In theory, we should check that this package's use of nmspinning is still valid in each release, but there is no way to automate that and I don't realistically seeing checking happening beyond verifying tests work. Additionally, the existing use is already suspect. :) The good news is the misuse is likely to cause scheduling issues, not memory corruption. PiperOrigin-RevId: 505114683
This commit is contained in:
committed by
gVisor bot
parent
c4fe64c5ef
commit
a8d6cc4072
+25
-2
@@ -1,10 +1,33 @@
|
||||
load("//tools:defs.bzl", "go_library", "go_test")
|
||||
load("//tools:defs.bzl", "arch_genrule", "go_library", "go_test", "select_arch")
|
||||
load("//tools/nogo:defs.bzl", "nogo_facts")
|
||||
|
||||
package(
|
||||
default_visibility = ["//:sandbox"],
|
||||
licenses = ["notice"],
|
||||
)
|
||||
|
||||
nogo_facts(
|
||||
name = "runtime_spinning_impl",
|
||||
srcs = ["runtime.go"],
|
||||
output = "runtime_spinning_impl.s",
|
||||
template = select_arch(
|
||||
amd64 = "runtime_spinning_amd64.s",
|
||||
arm64 = "runtime_spinning_other.s",
|
||||
),
|
||||
)
|
||||
|
||||
# For arm64 (or any !amd64), this will generate runtime_spinning_impl_arm64.s,
|
||||
# which is a copy of the (empty) runtime_spinning_other.s.
|
||||
#
|
||||
# On the go branch, only amd64 and arm64 will have have files, other arches
|
||||
# won't select any of these files. That is fine because the contents only
|
||||
# matter for amd64 anyway.
|
||||
arch_genrule(
|
||||
name = "runtime_spinning_impl_arch",
|
||||
src = ":runtime_spinning_impl",
|
||||
template = "runtime_spinning_impl_%s.s",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "sync",
|
||||
srcs = [
|
||||
@@ -21,12 +44,12 @@ go_library(
|
||||
"race_arm64.s",
|
||||
"race_unsafe.go",
|
||||
"runtime_amd64.go",
|
||||
"runtime_amd64.s",
|
||||
"runtime_other.go",
|
||||
"runtime_unsafe.go",
|
||||
"rwmutex_unsafe.go",
|
||||
"seqcount.go",
|
||||
"sync.go",
|
||||
":runtime_spinning_impl_arch",
|
||||
],
|
||||
marshal = False,
|
||||
stateify = False,
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2023 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package sync
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// Dummy reference for facts.
|
||||
const _ = runtime.Compiler
|
||||
@@ -3,8 +3,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build amd64 && go1.8 && !go1.21 && !goexperiment.staticlockranking
|
||||
// +build amd64,go1.8,!go1.21,!goexperiment.staticlockranking
|
||||
//go:build amd64
|
||||
|
||||
package sync
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build amd64 && go1.14 && !go1.21 && !goexperiment.staticlockranking
|
||||
// +build amd64,go1.14,!go1.21,!goexperiment.staticlockranking
|
||||
//go:build amd64
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
#define NMSPINNING_OFFSET {{ .import.runtime.schedt.nmspinning.Offset }}
|
||||
|
||||
TEXT ·addrOfSpinning(SB),NOSPLIT,$0-8
|
||||
// The offset specified here is the nmspinning value in sched.
|
||||
LEAQ runtime·sched(SB), AX
|
||||
ADDQ $92, AX
|
||||
ADDQ $NMSPINNING_OFFSET, AX
|
||||
MOVQ AX, ret+0(FP)
|
||||
RET
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2023 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build !amd64
|
||||
|
||||
// This file is intentionally left blank. Other arches don't use
|
||||
// addrOfSpinning, but we still need an input to the nogo temlate rule.
|
||||
Reference in New Issue
Block a user