Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp1277575rdb; Fri, 20 Oct 2023 13:46:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHurxmaw5PjNrdJMfB4oAOb0lg2r7F35BGPN5k8YAkIxtinuZnN1HXmsg3Hh3ZoRdcBSxDe X-Received: by 2002:a05:6358:7e07:b0:166:f338:78e3 with SMTP id o7-20020a0563587e0700b00166f33878e3mr3590716rwm.21.1697834777073; Fri, 20 Oct 2023 13:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697834777; cv=none; d=google.com; s=arc-20160816; b=1I8OC6RA/sVQNx6yTdppwazuLrtGZOo2aQwFMjesLc20Z5PMSLJ4Shqgg1zb548aM6 JORWZNJgXbCIZSwsNuyu5CcWNVrq7jvgdFNO+Q/2cme84XCxDu8OusPzPOHouOh1Lcxh mlFNSzK9Gn1mZAO26jvvqKPBhXACVY9LlLcehLPD5z9oomrD5t6Vzfwnn3mCXHTcB9Ee v1o97v/Jq/IxWUVUP5gcVrgP9tN1KsR2trauJR+HnGkKwkBAKV7to5t3ByT78uUNA7oI jFhbmnJWYX8sDfbVI7ILwDomX+E4iEoENCwZigSfTLxWPC+hdCrUsUIUO6NYUskssV44 W/7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/363Ck6ML1XM7ZYyVTDe7YNHEqM+JbJAFbfKlaD1Q1k=; fh=lbJsPO+ZRDN9baDq/BZnnNH6CGOpZtNT0YCi3hapTHQ=; b=rf3daz8+QKn/KKT0hbRZDqNDWLdxlSbWzyzxlgJxtxHmOQ7hC7/ci60dUIsyvDW5mV vQRSQh5O9XulXhuiWIftX1Qf7luJ8FB4mG6TFw9d1S3AOp5xYtMjOwymFcgFC3HWu+ka 3bJWaZuVyAYjlQJo9kBvrRt7U5MsWTLZxavOFFUgwCtH2aO4jMbAD4fQzh4sCMm2ZN1v rdupLDYexauIDfMRdbyM0WW5UcDKyMd79ByEcqFyVp0VomoXTXo3CyfKAU5dZ9ZaSOMy w4vpTvL0XFM271B01kt0VIzXk0IzgjlHrIFPtbx5GlAEJbipgUZrJtmAgtBNCrJK9LdW UzDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TgfSmSbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id z126-20020a633384000000b005774cf04028si2548703pgz.764.2023.10.20.13.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 13:46:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TgfSmSbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3901B804321F; Fri, 20 Oct 2023 13:46:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232326AbjJTUpU (ORCPT + 99 others); Fri, 20 Oct 2023 16:45:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230408AbjJTUpP (ORCPT ); Fri, 20 Oct 2023 16:45:15 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D711D73; Fri, 20 Oct 2023 13:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697834711; x=1729370711; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=0qW8gkQ9cQn9nJIAFp1D4GChim4j3ri4y26baGhJi2U=; b=TgfSmSbN2UWoYOR68QBC3ieQZ05CW1/XqLHaJxayGBCoJn/5/ybDPij/ EYG4rXAafabNr1tzgTAlVhftdr7xGEwHdld8P7HZBI9rg0vdFPTs+XkP+ 4dYd+5V1U0XAO0ZsU0LzeGILbka7tIEj17kwG0izuM0XibxtlSQlVlMnP szjlDwHWh9XBMCE6VdHcEZUKJ17aRpCfHp8GdfuKuH23km6dyy6yXqVVP un76a1JOnAPFcfe+GXBCDZkEiLesavYqajCpNi1MwUE102s5vROJ7S3mx gzaYTnX1dY0T3aoJ0x0JAFSOInqsiPsj5FZG+RouyItpLFdxnucZgAzpz w==; X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="371640238" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="371640238" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 13:45:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="931117494" X-IronPort-AV: E=Sophos;i="6.03,239,1694761200"; d="scan'208";a="931117494" Received: from hkchanda-mobl.amr.corp.intel.com (HELO desk) ([10.209.90.113]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 13:45:09 -0700 Date: Fri, 20 Oct 2023 13:45:09 -0700 From: Pawan Gupta To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Andy Lutomirski , Jonathan Corbet , Sean Christopherson , Paolo Bonzini , tony.luck@intel.com, ak@linux.intel.com, tim.c.chen@linux.intel.com Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, Alyssa Milburn , Daniel Sneddon , antonio.gomez.iglesias@linux.intel.com, Pawan Gupta Subject: [PATCH 3/6] x86/entry_32: Add VERW just before userspace transition Message-ID: <20231020-delay-verw-v1-3-cff54096326d@linux.intel.com> X-Mailer: b4 0.12.3 References: <20231020-delay-verw-v1-0-cff54096326d@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231020-delay-verw-v1-0-cff54096326d@linux.intel.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 20 Oct 2023 13:46:00 -0700 (PDT) As done for entry_64, add support for executing VERW late in exit to user path for 32-bit mode. Signed-off-by: Pawan Gupta --- arch/x86/entry/entry_32.S | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index 6e6af42e044a..bbf77d2aab2e 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S @@ -886,6 +886,9 @@ SYM_FUNC_START(entry_SYSENTER_32) popfl popl %eax + /* Mitigate CPU data sampling attacks .e.g. MDS */ + USER_CLEAR_CPU_BUFFERS + /* * Return back to the vDSO, which will pop ecx and edx. * Don't bother with DS and ES (they already contain __USER_DS). @@ -954,6 +957,9 @@ restore_all_switch_stack: /* Restore user state */ RESTORE_REGS pop=4 # skip orig_eax/error_code + + /* Mitigate CPU data sampling attacks .e.g. MDS */ + USER_CLEAR_CPU_BUFFERS .Lirq_return: /* * ARCH_HAS_MEMBARRIER_SYNC_CORE rely on IRET core serialization @@ -1146,6 +1152,8 @@ SYM_CODE_START(asm_exc_nmi) /* Not on SYSENTER stack. */ call exc_nmi + /* Mitigate CPU data sampling attacks .e.g. MDS */ + USER_CLEAR_CPU_BUFFERS jmp .Lnmi_return .Lnmi_from_sysenter_stack: -- 2.34.1