lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 17 Nov 2022 11:26:53 -0800
From:   Isaku Yamahata <isaku.yamahata@...il.com>
To:     Chenyi Qiang <chenyi.qiang@...el.com>
Cc:     isaku.yamahata@...el.com, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org, isaku.yamahata@...il.com,
        Paolo Bonzini <pbonzini@...hat.com>, erdemaktas@...gle.com,
        Sean Christopherson <seanjc@...gle.com>,
        Sagi Shahar <sagis@...gle.com>,
        David Matlack <dmatlack@...gle.com>,
        Kai Huang <kai.huang@...el.com>
Subject: Re: [PATCH v10 049/108] KVM: x86/tdp_mmu: Support TDX private
 mapping for TDP MMU

On Wed, Nov 16, 2022 at 09:40:38AM +0800,
Chenyi Qiang <chenyi.qiang@...el.com> wrote:

> > +static int __must_check handle_changed_private_spte(struct kvm *kvm, gfn_t gfn,
> > +						    u64 old_spte, u64 new_spte,
> > +						    int level)
> > +{
> > +	bool was_present = is_shadow_present_pte(old_spte);
> > +	bool is_present = is_shadow_present_pte(new_spte);
> > +	bool was_leaf = was_present && is_last_spte(old_spte, level);
> > +	bool is_leaf = is_present && is_last_spte(new_spte, level);
> > +	kvm_pfn_t old_pfn = spte_to_pfn(old_spte);
> > +	kvm_pfn_t new_pfn = spte_to_pfn(new_spte);
> > +	int ret;
> 
> int ret = 0;
> 
> > +
> > +	lockdep_assert_held(&kvm->mmu_lock);
> > +	if (is_present) {
> > +		/* TDP MMU doesn't change present -> present */
> > +		KVM_BUG_ON(was_present, kvm);
> > +
> > +		/*
> > +		 * Use different call to either set up middle level
> > +		 * private page table, or leaf.
> > +		 */
> > +		if (is_leaf)
> > +			ret = static_call(kvm_x86_set_private_spte)(kvm, gfn, level, new_pfn);
> > +		else {
> > +			void *private_spt = get_private_spt(gfn, new_spte, level);
> > +
> > +			KVM_BUG_ON(!private_spt, kvm);
> > +			ret = static_call(kvm_x86_link_private_spt)(kvm, gfn, level, private_spt);
> > +		}
> > +	} else if (was_leaf) {
> > +		/* non-present -> non-present doesn't make sense. */
> > +		KVM_BUG_ON(!was_present, kvm);
> > +		/*
> > +		 * Zap private leaf SPTE.  Zapping private table is done
> > +		 * below in handle_removed_tdp_mmu_page().
> > +		 */
> > +		lockdep_assert_held_write(&kvm->mmu_lock);
> > +		ret = static_call(kvm_x86_zap_private_spte)(kvm, gfn, level);
> > +		if (!ret) {
> > +			ret = static_call(kvm_x86_remove_private_spte)(kvm, gfn, level, old_pfn);
> > +			WARN_ON_ONCE(ret);
> > +		}
> > +	}
> 
> Otherwise, "ret" may be returned without initialization. Then it will
> trigger the WARN_ON_ONCE(ret) after handle_changed_spte() in patch 48.

Thanks for catching it.  Compiler didn't complain it.  Maybe W=1 is needed.
-- 
Isaku Yamahata <isaku.yamahata@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ