Re: [RFC PATCH 13/39] KVM: guest_memfd: Make guest mem use guest mem inodes instead of anonymous inodes

Yan Zhao
2025-04-24T03:56:02Z

On Wed, Apr 23, 2025 at 01:22:00PM -0700, Ackerley Tng wrote:
> Yan Zhao <yan.y.zhao@intel.com> writes:
>
> > Hi Ackerley,
> >
> > Not sure if below nits have been resolved in your latest code.
> > I came across them and felt it's better to report them anyway.
> >
> > Apologies for any redundancy if you've already addressed them.
>
> No worries, thank you so much for your reviews!
>
> >
> > On Tue, Sep 10, 2024 at 11:43:44PM +0000, Ackerley Tng wrote:
> >> +static void kvm_gmem_init_mount(void)
> >> +{
> >> + kvm_gmem_mnt = kern_mount(&kvm_gmem_fs);
> >> + BUG_ON(IS_ERR(kvm_gmem_mnt));
> >> +
> >> + /* For giggles. Userspace can never map this anyways. */
> >> + kvm_gmem_mnt->mnt_flags |= MNT_NOEXEC;
> >> +}
> >> +
> >> static struct file_operations kvm_gmem_fops = {
> >> .open = generic_file_open,
> >> .release = kvm_gmem_release,
> >> @@ -311,6 +348,8 @@ static struct file_operations kvm_gmem_fops = {
> >> void kvm_gmem_init(struct module *module)
> >> {
> >> kvm_gmem_fops.owner = module;
> >> +
> >> + kvm_gmem_init_mount();
> >> }
> > When KVM is compiled as a module, looks "kern_unmount(kvm_gmem_mnt)" is
> > missing in the kvm_exit() path.
> >
> > This may lead to kernel oops when executing "sync" after KVM is unloaded or
> > reloaded.
> >
>
> Thanks, Fuad will be addressing this in a revision of [1].
>
> > BTW, there're lots of symbols not exported under mm.
> >
>
> Thanks again, is there a good way to do a build test for symbols not
> being exported? What CONFIG flags do you use?
I compiled kvm.ko and kvm-intel.ko as modules.

CONFIG_KVM=m
CONFIG_KVM_INTEL=m
CONFIG_KVM_INTEL_TDX=y