• Mostafa Saleh's avatar
    KVM: arm64: Use different pointer authentication keys for pKVM · 8c15c2a0
    Mostafa Saleh authored
    When the use of pointer authentication is enabled in the kernel it
    applies to both the kernel itself as well as KVM's nVHE hypervisor. The
    same keys are used for both the kernel and the nVHE hypervisor, which is
    less than desirable for pKVM as the host is not trusted at runtime.
    
    Naturally, the fix is to use a different set of keys for the hypervisor
    when running in protected mode. Have the host generate a new set of keys
    for the hypervisor before deprivileging the kernel. While there might be
    other sources of random directly available at EL2, this keeps the
    implementation simple, and the host is trusted anyways until it is
    deprivileged.
    
    Since the host and hypervisor no longer share a set of pointer
    authentication keys, start context switching them on the host entry/exit
    path exactly as we do for guest entry/exit. There is no need to handle
    CPU migration as the nVHE code is not migratable in the first place.
    Signed-off-by: default avatarMostafa Saleh <smostafa@google.com>
    Link: https://lore.kernel.org/r/20230614122600.2098901-1-smostafa@google.comSigned-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
    8c15c2a0
host.S 7.89 KB