github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/ring0/pagetables/pcids_aarch64.go (about)

     1  // Copyright 2020 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // +build arm64
    16  
    17  package pagetables
    18  
    19  // limitPCID is the maximum value of PCIDs.
    20  //
    21  // In VMSAv8-64, the PCID(ASID) size is an IMPLEMENTATION DEFINED choice
    22  // of 8 bits or 16 bits, and ID_AA64MMFR0_EL1.ASIDBits identifies the
    23  // supported size. When an implementation supports a 16-bit ASID, TCR_ELx.AS
    24  // selects whether the top 8 bits of the ASID are used.
    25  var limitPCID uint16
    26  
    27  // GetASIDBits return the system ASID bits, 8 or 16 bits.
    28  func GetASIDBits() uint8
    29  
    30  func init() {
    31  	limitPCID = uint16(1)<<GetASIDBits() - 1
    32  }