mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Merge pull request #2235 from xiaobo55x:pcid
PiperOrigin-RevId: 307166482
This commit is contained in:
@@ -81,6 +81,9 @@ go_library(
|
||||
"pagetables_arm64.go",
|
||||
"pagetables_x86.go",
|
||||
"pcids.go",
|
||||
"pcids_aarch64.go",
|
||||
"pcids_aarch64.s",
|
||||
"pcids_x86.go",
|
||||
"walker_amd64.go",
|
||||
"walker_arm64.go",
|
||||
"walker_empty.go",
|
||||
|
||||
@@ -18,9 +18,6 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/sync"
|
||||
)
|
||||
|
||||
// limitPCID is the number of valid PCIDs.
|
||||
const limitPCID = 4096
|
||||
|
||||
// PCIDs is a simple PCID database.
|
||||
//
|
||||
// This is not protected by locks and is thus suitable for use only with a
|
||||
@@ -44,7 +41,7 @@ type PCIDs struct {
|
||||
//
|
||||
// Nil is returned iff the start and size are out of range.
|
||||
func NewPCIDs(start, size uint16) *PCIDs {
|
||||
if start+uint16(size) >= limitPCID {
|
||||
if start+uint16(size) > limitPCID {
|
||||
return nil // See comment.
|
||||
}
|
||||
p := &PCIDs{
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright 2020 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.
|
||||
|
||||
// +build arm64
|
||||
|
||||
package pagetables
|
||||
|
||||
// limitPCID is the maximum value of PCIDs.
|
||||
//
|
||||
// In VMSAv8-64, the PCID(ASID) size is an IMPLEMENTATION DEFINED choice
|
||||
// of 8 bits or 16 bits, and ID_AA64MMFR0_EL1.ASIDBits identifies the
|
||||
// supported size. When an implementation supports a 16-bit ASID, TCR_ELx.AS
|
||||
// selects whether the top 8 bits of the ASID are used.
|
||||
var limitPCID uint16
|
||||
|
||||
// GetASIDBits return the system ASID bits, 8 or 16 bits.
|
||||
func GetASIDBits() uint8
|
||||
|
||||
func init() {
|
||||
limitPCID = uint16(1)<<GetASIDBits() - 1
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2020 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.
|
||||
|
||||
// +build arm64
|
||||
|
||||
#include "funcdata.h"
|
||||
#include "textflag.h"
|
||||
|
||||
#define ID_AA64MMFR0_ASIDBITS_SHIFT 4
|
||||
#define ID_AA64MMFR0_ASIDBITS_16 2
|
||||
#define TCR_EL1_AS_BIT 36
|
||||
|
||||
// GetASIDBits return the system ASID bits, 8 or 16 bits.
|
||||
//
|
||||
// func GetASIDBits() uint8
|
||||
TEXT ·GetASIDBits(SB),NOSPLIT,$0-1
|
||||
// First, check whether 16bits ASID is supported.
|
||||
// ID_AA64MMFR0_EL1.ASIDBITS[7:4] == 0010.
|
||||
WORD $0xd5380700 // MRS ID_AA64MMFR0_EL1, R0
|
||||
UBFX $ID_AA64MMFR0_ASIDBITS_SHIFT, R0, $4, R0
|
||||
CMPW $ID_AA64MMFR0_ASIDBITS_16, R0
|
||||
BNE bits_8
|
||||
|
||||
// Second, check whether 16bits ASID is enabled.
|
||||
// TCR_EL1.AS[36] == 1.
|
||||
WORD $0xd5382040 // MRS TCR_EL1, R0
|
||||
TBZ $TCR_EL1_AS_BIT, R0, bits_8
|
||||
MOVD $16, R0
|
||||
B done
|
||||
bits_8:
|
||||
MOVD $8, R0
|
||||
done:
|
||||
MOVB R0, ret+0(FP)
|
||||
RET
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2020 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.
|
||||
|
||||
// +build i386 amd64
|
||||
|
||||
package pagetables
|
||||
|
||||
// limitPCID is the maximum value of valid PCIDs.
|
||||
const limitPCID = 4095
|
||||
Reference in New Issue
Block a user