On Mon, Jan 11, 2021 at 07:13:27PM +0100, Philippe Mathieu-Daudé wrote: > 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@xxxxxxxxxxxxxxxxxxxxx> > > Reviewed-by: Richard Henderson <richard.henderson@xxxxxxxxxx> > > --- > > 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? It's made moot by changes in the next spin. > > Otherwise: > Reviewed-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx> > > > + return sgmc->encrypt_data(sgm, ptr, len); > > + } > > + } > > + > > + return 1; > > +} > -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature