From nobody Mon Feb 9 13:37:11 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 7647D32D0EE for ; Thu, 13 Nov 2025 23:37:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763077076; cv=none; b=Zn8KckO3sNEQqHUHxUU7K7sZRHsDECmAgP11IXmovSZCBkZf0oMPsczO6MpuWa8nyfeyZ4hilQQTONEXACQxrC/3xgxo/Krr4UoNr6+nqSGbc69J8fjSLeUlgnbFqhLp/qUPRu5gahVOBwW8jxRsy15ndy1J4tcSax+fvsGKfkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763077076; c=relaxed/simple; bh=9/ZEG9qS0v5yHmDM5mNncrn+pJi6DDL3CwwPd50ORBk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dQYhLp/k8HDgctyv+MpeuQ1nqtaqmySur4WZTOhTuuAn/nKyCbS1gWGpB5hkOwln4158M7DYUB28kNmJKXo1qLKaGd30dfNECsdP9eQArsuvZTWDtn3S0CRtRxU729jTjuPgGu4Bq3dKlsTAhaW7U9nZZGcr+kn/oF4X+deEDpg= 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=CM8oshXT; arc=none smtp.client-ip=209.85.214.202 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="CM8oshXT" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-297fbfb4e53so26638925ad.1 for ; Thu, 13 Nov 2025 15:37:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1763077074; x=1763681874; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=jX3Feop83q2z4Q+hCWNf+/7P2WvpoKPC/BxcXVensJI=; b=CM8oshXTrd4XHk/baxaU0GMqOxQlqdrluN59AhGsW1YbkYpMx6pa0n2F8RK7UtYr3m /EWY8ba/0bv76djwtHkonpKPqJHDcf6dTRMgkcvqj0tX6VnnTFV2/paAHY+xBf95WmoX 2Xu75IlTklSzYmYrucrJ2flo67fJLIZf5Qf0DxTg8oE64XTYBWwlPLcSV+2H+szuRdkH qxQo9dOimE8WXzI30bLZTzMlHMmDAVwLxYqzb3SOKgL4uWkC339LC6S72Xg/whzWGvVW MA7fEIZa6va2Ugy5zyGEtRl8k2s+K+R7M9Cp1fIFLV/VhC6C1CZj7sPHvHNsO/XfqIOX Cs8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763077074; x=1763681874; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jX3Feop83q2z4Q+hCWNf+/7P2WvpoKPC/BxcXVensJI=; b=svG+ynSUxsTjsbIVo01J26vJtVnBisFsRe7gCerWNVZ9rJZgnzA9GcbH1T/zvZMPHE j0KH+JcIyxFH33j9f+vb7Pf27BpeFw4DELGAPX6WjeiReL/9oyJ5M/2E/kMRD3g65VmO YgRoFgFer2vwIeeN+EJZdDwOQesAYDk57LxK0dCGhQwxsRZobXm/Jc75CAAB0eX28OA0 TL9XkGA6ZIT2qOYeYOdreATtNfcLfTHXhY9ATUglqi6ZFeIF/gY4cBhdI43ySAzk2x1d D5tamHE364tUP8sApNlZX8t0/qZPAEd6Oixc1uW6mE+zvntdRt+1o7H6DWT6qk/woIcL Rgsw== X-Forwarded-Encrypted: i=1; AJvYcCXpf6Apaa1hC2fBF/9sVYFl3x1wFaL5xoyQ6oIyvbL+BxtM3R1WZRNYmuvHx/exl3vYoGNqtbayaJe0X/U=@vger.kernel.org X-Gm-Message-State: AOJu0YxP1dT6JKhDO6Ttp2dM1kZ22EvLf+IenzDUccvZAqnNMusCresf +LKJ45J5LM5UprJofDz80dJmQNa142xTwckDyUgICXwqjpWuON45IQrZ1yIMRyCgxscnKfCVJ6w nWjAZ0g== X-Google-Smtp-Source: AGHT+IHJOzZDPILzi8nste2JY0ljSD09D7AMJE4IfZRr7nMUO63lLcqgpVvpjyngQFZ2bq/QcuhX1dI5i0Q= X-Received: from plrq24.prod.google.com ([2002:a17:902:b118:b0:298:a8:6ab2]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:b0d:b0:295:70cc:8ec4 with SMTP id d9443c01a7336-2986a74b360mr8908115ad.51.1763077073730; Thu, 13 Nov 2025 15:37:53 -0800 (PST) Reply-To: Sean Christopherson Date: Thu, 13 Nov 2025 15:37:40 -0800 In-Reply-To: <20251113233746.1703361-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20251113233746.1703361-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.rc1.455.g30608eb744-goog Message-ID: <20251113233746.1703361-4-seanjc@google.com> Subject: [PATCH v5 3/9] x86/bugs: Decouple ALTERNATIVE usage from VERW macro definition From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Pawan Gupta , Brendan Jackman Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Decouple the use of ALTERNATIVE from the encoding of VERW to clear CPU buffers so that KVM can use ALTERNATIVE_2 to handle "always clear buffers" and "clear if guest can access host MMIO" in a single statement. No functional change intended. Reviewed-by: Brendan Jackman Reviewed-by: Pawan Gupta Signed-off-by: Sean Christopherson --- arch/x86/include/asm/nospec-branch.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/no= spec-branch.h index 08ed5a2e46a5..8b4885a1b2ef 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -308,24 +308,24 @@ * CFLAGS.ZF. * Note: Only the memory operand variant of VERW clears the CPU buffers. */ -.macro __CLEAR_CPU_BUFFERS feature #ifdef CONFIG_X86_64 - ALTERNATIVE "", "verw x86_verw_sel(%rip)", \feature +#define VERW verw x86_verw_sel(%rip) #else - /* - * In 32bit mode, the memory operand must be a %cs reference. The data - * segments may not be usable (vm86 mode), and the stack segment may not - * be flat (ESPFIX32). - */ - ALTERNATIVE "", "verw %cs:x86_verw_sel", \feature +/* + * In 32bit mode, the memory operand must be a %cs reference. The data seg= ments + * may not be usable (vm86 mode), and the stack segment may not be flat (E= SPFIX32). + */ +#define VERW verw %cs:x86_verw_sel #endif -.endm =20 +#define __CLEAR_CPU_BUFFERS __stringify(VERW) + +/* If necessary, emit VERW on exit-to-userspace to clear CPU buffers. */ #define CLEAR_CPU_BUFFERS \ - __CLEAR_CPU_BUFFERS X86_FEATURE_CLEAR_CPU_BUF + ALTERNATIVE "", __CLEAR_CPU_BUFFERS, X86_FEATURE_CLEAR_CPU_BUF =20 #define VM_CLEAR_CPU_BUFFERS \ - __CLEAR_CPU_BUFFERS X86_FEATURE_CLEAR_CPU_BUF_VM + ALTERNATIVE "", __CLEAR_CPU_BUFFERS, X86_FEATURE_CLEAR_CPU_BUF_VM =20 #ifdef CONFIG_X86_64 .macro CLEAR_BRANCH_HISTORY --=20 2.52.0.rc1.455.g30608eb744-goog