lkml.org 
[lkml]   [2021]   [Oct]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [RFC 02/16] KVM: selftests: add hooks for managing encrypted guest memory
On Wed, Oct 20, 2021 at 8:46 PM Michael Roth <michael.roth@amd.com> wrote:
>
> On Mon, Oct 18, 2021 at 08:00:00AM -0700, Mingwei Zhang wrote:
> > > +void vm_set_memory_encryption(struct kvm_vm *vm, bool enc_by_default, bool has_enc_bit,
> > > + uint8_t enc_bit)
> > > +{
> > > + vm->memcrypt.enabled = true;
> > > + vm->memcrypt.enc_by_default = enc_by_default;
> > > + vm->memcrypt.has_enc_bit = has_enc_bit;
> > > + vm->memcrypt.enc_bit = enc_bit;
> > > +}
> > > +
> > > +struct sparsebit *
> > > +vm_get_encrypted_phy_pages(struct kvm_vm *vm, int slot, vm_paddr_t *gpa_start,
> > > + uint64_t *size)
> > > +{
> > > + struct userspace_mem_region *region;
> > > + struct sparsebit *encrypted_phy_pages;
> > > +
> > > + if (!vm->memcrypt.enabled)
> > > + return NULL;
> > > +
> > > + region = memslot2region(vm, slot);
> > > + if (!region)
> > > + return NULL;
> > > +
> > > + encrypted_phy_pages = sparsebit_alloc();
> > > + sparsebit_copy(encrypted_phy_pages, region->encrypted_phy_pages);
> >
> > Do we have to make a copy for the sparsebit? Why not just return the
> > pointer? By looking at your subsequent patches, I find that this data
> > structure seems to be just read-only?
>
> Yes, it's only intended to be used for read access. But I'll if I can
> enforce that without the need to use a copy.
>

Understood. Thanks for the clarification. Yeah, I think both making a
copy and returning a const pointer should work. I will leave that to
you then.

Thanks.
-Mingwei

\
 
 \ /
  Last update: 2021-10-26 17:49    [W:0.095 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site