[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [for-6.0 v5 06/13] securable guest memory: Decouple kvm_memcrypt_*()
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [for-6.0 v5 06/13] securable guest memory: Decouple kvm_memcrypt_*() helpers from KVM |
Date: |
Mon, 11 Jan 2021 19:13:27 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 |
On 12/4/20 6:44 AM, David Gibson wrote:
> The kvm_memcrypt_enabled() and kvm_memcrypt_encrypt_data() helper functions
> don't conceptually have any connection to KVM (although it's not possible
> in practice to use them without it).
>
> They also rely on looking at the global KVMState. But the same information
> is available from the machine, and the only existing callers have natural
> access to the machine state.
>
> Therefore, move and rename them to helpers in securable-guest-memory.h,
> taking an explicit machine parameter.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/kvm/kvm-all.c | 27 --------------------
> accel/stubs/kvm-stub.c | 10 --------
> hw/i386/pc_sysfw.c | 6 +++--
> include/exec/securable-guest-memory.h | 36 +++++++++++++++++++++++++++
> include/sysemu/kvm.h | 17 -------------
> 5 files changed, 40 insertions(+), 56 deletions(-)
...
> +static inline int securable_guest_memory_encrypt(MachineState *machine,
> + uint8_t *ptr, uint64_t len)
> +{
> + SecurableGuestMemory *sgm = machine->sgm;
> +
> + if (sgm) {
> + SecurableGuestMemoryClass *sgmc =
> SECURABLE_GUEST_MEMORY_GET_CLASS(sgm);
> +
> + if (sgmc->encrypt_data) {
Can this ever happen? Maybe use assert(sgmc->encrypt_data) instead?
Otherwise:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> + return sgmc->encrypt_data(sgm, ptr, len);
> + }
> + }
> +
> + return 1;
> +}
- Re: [for-6.0 v5 06/13] securable guest memory: Decouple kvm_memcrypt_*() helpers from KVM,
Philippe Mathieu-Daudé <=