gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/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  //go:build arm64
    16  // +build arm64
    17  
    18  package pagetables
    19  
    20  // limitPCID is the maximum value of PCIDs.
    21  //
    22  // In VMSAv8-64, the PCID(ASID) size is an IMPLEMENTATION DEFINED choice
    23  // of 8 bits or 16 bits, and ID_AA64MMFR0_EL1.ASIDBits identifies the
    24  // supported size. When an implementation supports a 16-bit ASID, TCR_ELx.AS
    25  // selects whether the top 8 bits of the ASID are used.
    26  var limitPCID uint16
    27  
    28  // GetASIDBits return the system ASID bits, 8 or 16 bits.
    29  func GetASIDBits() uint8
    30  
    31  func init() {
    32  	limitPCID = uint16(1)<<GetASIDBits() - 1
    33  }