From nobody Mon Apr 6 08:05:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A3C9C38145 for ; Thu, 8 Sep 2022 17:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231495AbiIHRF3 (ORCPT ); Thu, 8 Sep 2022 13:05:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230178AbiIHRF1 (ORCPT ); Thu, 8 Sep 2022 13:05:27 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9873A56BB0 for ; Thu, 8 Sep 2022 10:05:26 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-345188a7247so116360687b3.22 for ; Thu, 08 Sep 2022 10:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=Tb/TR0D6+TZRh/xClS3B2006d7nEi2kvzg0PMDr41zU=; b=l/IF7eiywF7DijJmWs32L+ESvrnZzL6ujSjiN4HQb8jq2jnV9CuVwrYRyvUmVouiKs dGSq7+5JV1/331c4SHuQ2axXuzASrDRiCykmau7/YAB/h6yuoUJiLQiruNz9QYPfH8s2 apumrVo03AcQF5HCpuvcGKBX/1SNMHAlDD7IV3vX5W8EA7ON01T6LZh8nicXY/7IQoKM xuWfWbi13xBh4AXn6zSGIR0w7R6RuDoAjqYWFYkloXL6cUmtKc1e4RpCXKFg2bLwmaHz XIDDK3wKIdm72pwRN+zg7whNxAZ+Y5CxkEjF3byH2rZImMcabz/7ubpQxqPOiisegwgm Qlkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=Tb/TR0D6+TZRh/xClS3B2006d7nEi2kvzg0PMDr41zU=; b=cRkYnZaDFkNLbgwLsWNRX945imt3DNRrURFKwxYj8ckIp2dfkbYf7M0ik4HmBZN4gv wePrEOpXs1qv0POiyFTkogn+d8qxwzr586HYm+KUZb8vjkjmq98CN9sdERJY/JpqLHsA G9EItDW8D6BAHBrG9YWaYD+vTWnqY/4Aa1jLl48xQVAdiwcuytdxtLfyk6LUSSapP+ZO rA0yxmZnlfd4+PodFgMicf9cKWqN1URrbij/+j7JRoUraN+FsGG3QshRP4D6leQmaIyi PonmA+Zin1OGPV+PFRvzzLvYDfq+p8Cp90VW55aRZdC9DxvMkXbuOrIVop/6Bts0RphX HTyw== X-Gm-Message-State: ACgBeo0cqcL474/hUfEdlcQ/f72lqTCof8KfoPaPlm775Rx+rW9Zopr/ nZffwHaZ2pkj6Lra98ac0rBTeSk2VJq/sQ== X-Google-Smtp-Source: AA6agR708d+P/Ik0lcxvg0vQvB6mz9WCwn4p5mhIR5Ov5qTjPmwpUuCMLzpOMl7grh7S3VO9/1R1FkTtJXMFWw== X-Received: from acdunlap03.bve.corp.google.com ([2620:15c:29:203:b753:a87e:9aa4:f86e]) (user=acdunlap job=sendgmr) by 2002:a05:6902:3c6:b0:694:1088:5448 with SMTP id g6-20020a05690203c600b0069410885448mr8476959ybs.410.1662656725853; Thu, 08 Sep 2022 10:05:25 -0700 (PDT) Date: Thu, 8 Sep 2022 10:04:56 -0700 In-Reply-To: <20220812183501.3555820-1-acdunlap@google.com> Mime-Version: 1.0 References: <20220812183501.3555820-1-acdunlap@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220908170456.3177635-1-acdunlap@google.com> Subject: [PATCH v2 RESEND] x86/asm: Force native_apic_mem_read to use mov From: Adam Dunlap To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Nathan Chancellor , Nick Desaulniers , Tom Rix , "Kirill A. Shutemov" , Sean Christopherson , Kuppuswamy Sathyanarayanan , Andi Kleen , Adam Dunlap , Ben Dooks , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Peter Gonda Cc: Jacob Xu , Alper Gun , Marc Orr Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previously, when compiled with clang, native_apic_mem_read gets inlined into __xapic_wait_icr_idle and optimized to a testl instruction. When run in a VM with SEV-ES enabled, it attempts to emulate this instruction, but the emulator does not support it. Instead, use inline assembly to force native_apic_mem_read to use the mov instruction which is supported by the emulator. Signed-off-by: Adam Dunlap --- V1 -> V2: Replaced asm with readl function which does the same thing arch/x86/include/asm/apic.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index 3415321c8240..b4c9034aa073 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -12,6 +12,7 @@ #include #include #include +#include =20 #define ARCH_APICTIMER_STOPS_ON_C3 1 =20 @@ -109,7 +110,7 @@ static inline void native_apic_mem_write(u32 reg, u32 v) =20 static inline u32 native_apic_mem_read(u32 reg) { - return *((volatile u32 *)(APIC_BASE + reg)); + return readl((void __iomem *)(APIC_BASE + reg)); } =20 extern void native_apic_wait_icr_idle(void); --=20 2.37.1.559.g78731f0fdb-goog