On Thu, Aug 29, 2024 at 12:27:35AM +0100, Mark Brown wrote: > All GCS operations at EL0 must happen on a page which is marked as > having UnprivGCS access, including read operations. If a GCS operation > attempts to access a page without this then it will generate a data > abort with the GCS bit set in ESR_EL1.ISS2. > > EL0 may validly generate such faults, for example due to copy on write > which will cause the GCS data to be stored in a read only page with no > GCS permissions until the actual copy happens. Since UnprivGCS allows > both reads and writes to the GCS (though only through GCS operations) we > need to ensure that the memory management subsystem handles GCS accesses > as writes at all times. Do this by adding FAULT_FLAG_WRITE to any GCS > page faults, adding handling to ensure that invalid cases are identfied > as such early so the memory management core does not think they will > succeed. The core cannot distinguish between VMAs which are generally > writeable and VMAs which are only writeable through GCS operations. > > EL1 may validly write to EL0 GCS for management purposes (eg, while > initialising with cap tokens). > > We also report any GCS faults in VMAs not marked as part of a GCS as > access violations, causing a fault to be delivered to userspace if it > attempts to do GCS operations outside a GCS. > > Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@xxxxxxxxxx> > Signed-off-by: Mark Brown <broonie@xxxxxxxxxx> Reviewed-by: Catalin Marinas <catalin.marinas@xxxxxxx>