From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A69F533342E for ; Thu, 26 Feb 2026 23:43:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772149391; cv=none; b=gm21zAAnCNMg+A7UyzPKa15BREEr3t3i0In66/YAiQ4o7iksMf4n66KEyaUtf5GoYIzMCbyNQhzevhym/56cNJrgPBV5clNGypUFHYCdX1jiYrOCItM7PTP1qxKEFQ935k6/HUMJT9ITE2HC8qf4wJZ7vaz/YlN8KUA/gr2y9lE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772149391; c=relaxed/simple; bh=nYT1y/hhQW/86aS4ZN4OJ957tRCJesbnqHhi2ZZK9B8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=MUBRzzV26xY0Lx0/ZFe0jFvBaRzwZsaalCEIIbBzstKJrC7ergGoVMDJHv7tOQR7ZbGkrDkAyHU+n9r0JmXQwtXataN6vHtD+HtiZZob0oPxiP2phh8Jle5OwCAg2byAocfHNFG/YsoO4NNvb2zv05VJiDkotLRC5ytGd7qKKzM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qCYTTfVl; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qCYTTfVl" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-3595485abbbso720569a91.2 for ; Thu, 26 Feb 2026 15:43:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772149385; x=1772754185; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=5xV9Fp9Mp3wKt/HL2xKn2gAO+TqSS/NXayrdSUMZqB8=; b=qCYTTfVlC5qn1oHz+Yt5dDM0Wbprkq41lljrj9akTAHgLb6cwitfub0zVDC9L3kQzd j9cOt6j5Pcei1A3/pxH+yCYN1BUJSPH5/dradmt+e4N/exOmCCftjKWWzCE7S7s8ZlmC ZS7hGiFTDwARJeczyDmkq58s/+FetZDp8wQQtYQbClPrtyHJjmZaXJl96OOnTh4GDH2H X7daTeVOqlUpdv8wPsAg/NFhq3ocM46yHsRuUJGjmE6ziIGZTfBEZw9ZMj77TaDZ2td1 oOW8GGpbOdc+F2tA3lvrb2YjybB5aVCYfS4ok8pBvF14W1rpsXpUQ908VyAQ2VTea7QG 7X5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772149385; x=1772754185; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5xV9Fp9Mp3wKt/HL2xKn2gAO+TqSS/NXayrdSUMZqB8=; b=QKf2OQMLLiZbkh7cgNHGCCQCEgf8vmyfL26Jg1er6sVHGOmxotnJWR046VHh6jXEQn PWVrp9Lc09bEgiCbJcpcFG1RAhKgOOnKKRc0nMkC+YhyWIqkLS7ielRy9dox/FeX1E6a fnQMg8ULeDnMFiH2NrEmZCjeBG+m/YaRg2bzNShzDADW5HOM04tvhxAR6PncKXlIscSx 0pn4kQKm8GmpD0QeiyotW+aMG4sdrY9kAlzzJZQcA9m6lHwinALf/8jl4Wght8eMLGPJ j4J/EZqFL33+gHKjqMffQtOtCqIm/CF8uyZfsWYm6D6nwVJEHQ/pUwQeA+xtMtV6xeuE d8/w== X-Forwarded-Encrypted: i=1; AJvYcCUNniHH/XLk0b9Pel1suiiRa7ioJkGfJNZjOnPH1Fwdxi0j6y4VXGy/6+fKjNagaRzk4BVgaSCL0kcpePQ=@vger.kernel.org X-Gm-Message-State: AOJu0Ywm1xRVDuSv5uM3AV6VEimIvnwTpyO49gqETFsWd6BzsBAWDEyo wwJFP+9KEBFqEKs/Ci6HdNP3r3F7tew/brGeb6Aq4dgjc1ovJIhEeb3DtwDyWWpJEU9dsQeNf96 LIC9spA== X-Received: from pjwo21.prod.google.com ([2002:a17:90a:d255:b0:356:213e:d56e]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5710:b0:356:23be:7ecb with SMTP id 98e67ed59e1d1-35965c34bc7mr627146a91.12.1772149384979; Thu, 26 Feb 2026 15:43:04 -0800 (PST) Date: Thu, 26 Feb 2026 15:43:03 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260214012702.2368778-1-seanjc@google.com> <20260214012702.2368778-8-seanjc@google.com> Message-ID: Subject: Re: [PATCH v3 07/16] KVM: SVM: Move core EFER.SVME enablement to kernel From: Sean Christopherson To: Chao Gao Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Kiryl Shutsemau , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Paolo Bonzini , linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, Xu Yilun , Dan Williams Content-Type: text/plain; charset="us-ascii" On Thu, Feb 26, 2026, Chao Gao wrote: > >-static inline void kvm_cpu_svm_disable(void) > >-{ > >- uint64_t efer; > >- > >- wrmsrq(MSR_VM_HSAVE_PA, 0); > >- rdmsrq(MSR_EFER, efer); > >- if (efer & EFER_SVME) { > >- /* > >- * Force GIF=1 prior to disabling SVM, e.g. to ensure INIT and > >- * NMI aren't blocked. > >- */ > >- stgi(); > >- wrmsrq(MSR_EFER, efer & ~EFER_SVME); > >- } > >-} > >- > > static void svm_emergency_disable_virtualization_cpu(void) > > { > >- virt_rebooting = true; > >- > >- kvm_cpu_svm_disable(); > >+ wrmsrq(MSR_VM_HSAVE_PA, 0); > > } > > > > static void svm_disable_virtualization_cpu(void) > >@@ -507,7 +489,7 @@ static void svm_disable_virtualization_cpu(void) > > if (tsc_scaling) > > __svm_write_tsc_multiplier(SVM_TSC_RATIO_DEFAULT); > > > >- kvm_cpu_svm_disable(); > >+ x86_svm_disable_virtualization_cpu(); > > There's a functional change here. The new x86_svm_disable_virtualization_cpu() > doesn't reset MSR_VM_HSAVE_PA, but the old kvm_cpu_svm_disable() does. Doh. I'll squash this as fixup, assuming there are no other goofs: diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 5f033bf3ba83..fc08450cb4b7 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -490,6 +490,7 @@ static void svm_disable_virtualization_cpu(void) __svm_write_tsc_multiplier(SVM_TSC_RATIO_DEFAULT); x86_svm_disable_virtualization_cpu(); + wrmsrq(MSR_VM_HSAVE_PA, 0); amd_pmu_disable_virt(); } Very nice catch! P.S. This reminded me that there's a lurking wart with __sev_snp_init_locked() where it forces MSR_VM_HSAVE_PA to '0' on all CPUs. That's firmly a "hypervisor" thing so it doesn't really fit here (and code wise it's also kludgy), just thought I'd mention it in case someone has a brilliant idea and/or runs into problems with it. IIRC, we ran into a problem where __sev_snp_init_locked() clobbered KVM's value, but I think the underlying problem was effectively fixed by commit 6f1d5a3513c2 ("KVM: SVM: Add support to initialize SEV/SNP functionality in KVM").