Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6865608rwd; Tue, 6 Jun 2023 03:08:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4sUuxQdpx3VAotdq9AY1XXWWl/qA+8FcqsIL9sZb7IFEWrwJeKdcCR3U1abMHUP2s8drY8 X-Received: by 2002:a17:90b:4fc2:b0:259:24c4:4de8 with SMTP id qa2-20020a17090b4fc200b0025924c44de8mr478287pjb.0.1686046082028; Tue, 06 Jun 2023 03:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686046082; cv=none; d=google.com; s=arc-20160816; b=CFbZn9tcxS5q1lyqzmbs84t9nCso3jW+h7dM3Y3d4l0U/0tQ3qtN00RK/a7OCWiehF ++mHfUcg197nTKQtio2sFJlljtkNxwGSWM4+KyAIDKcfgaQyz+Yu4NcJSvXgXHnpRXER Rn6PJPM7VDPQU6l2a3VrSxbasbIv2fdydvM5H4QVlMEvONGGyXuvcFr1RWeITfE/uT12 H2ImLXa58cUpPY46fOF2oc1nqTsUlCqRJP7GDQ84qgVr0fLsfAQX3rIPvGu0XAb0BJj9 eMNcrW2jgPErHmvbzQu8Nt0F3/SeVNSAoA5na5/HipGzj0bMnLYzSyvfpC1ty0z8o/gy Tb4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=T3Dl6lE396ODnEUhCB++ButNIQ5Le9Rd4gOXh3+keaM=; b=oOEYSuWQ6lS3/FeUF+igRDcyyfnelyUJGaANIxiScAqcXAVvbiSGZOaly+NlN7zpio MHD34NGCkJhWOxaPxJm+IcDa8t8GgN5pWbKnSvv+fFdlwN3MnHWTaYn3WUiCyOwCEJkV NTVAjsDUMiVighigLU2KT6jL9Dl9SwRRlofletZCBUOxKK1oevUrnoBrC9B0zLW9NEn5 DwMc5ZxpSqaH9LkYM/8d8DGLfjTUD9ArQ9NIv8cfBo+GRBjgcnN9z1916HytJQ8zlNlK VAw5hsWkwvdwM2V0jCZnz1L++iG5N3r6PsqracrxlDvj4RiL1Ye0gDqquPxsbn3fYGpo oaaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lrJtaNNn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u185-20020a6379c2000000b0050309caf60esi6937632pgc.750.2023.06.06.03.07.49; Tue, 06 Jun 2023 03:08:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lrJtaNNn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237376AbjFFJ4l (ORCPT + 99 others); Tue, 6 Jun 2023 05:56:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237326AbjFFJ4f (ORCPT ); Tue, 6 Jun 2023 05:56:35 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B4D4E6E for ; Tue, 6 Jun 2023 02:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686045393; x=1717581393; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Z2Dvf4mA1VzzTZjfh3y1HywjdJsGHa7T3oAn6+kI0iA=; b=lrJtaNNnH7FWLmvZEEXbkZAFk8ytjcBEkJ2Ib4EqFMFrn62OEC21CQKD 33J9nQDw+cEDLfV6mN+qFAHhkc0kzel5UZQR1A0wVNg1NQS60bH0UX74e emCSiyUUVVslko9h7woka7NCPhPbpgRDRjJTnOX6F3wEPsAn/wBHQgplw QYJP7g1NNiNfeIQBy/Ouy3+geak7uaY/salg/l1BTpcLB8WPsOX6k15ZR OrcrR2Vq+FM2k6CvZ77n82f3cRrorbyxJqC3nPClwFt12sT+Fs9U4gLGe /KEUnzomyMVIPaGzDuZSHSucXJwQAfSIyz8e4mw1kyvj1YPynxcacXlFl g==; X-IronPort-AV: E=McAfee;i="6600,9927,10732"; a="336249090" X-IronPort-AV: E=Sophos;i="6.00,219,1681196400"; d="scan'208";a="336249090" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2023 02:56:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10732"; a="853348525" X-IronPort-AV: E=Sophos;i="6.00,219,1681196400"; d="scan'208";a="853348525" Received: from rgraefe-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.58.173]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jun 2023 02:56:29 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 9F11F10A6A4; Tue, 6 Jun 2023 12:56:26 +0300 (+03) From: "Kirill A. Shutemov" To: dave.hansen@intel.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de Cc: decui@microsoft.com, rick.p.edgecombe@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, seanjc@google.com, thomas.lendacky@amd.com, x86@kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv3 0/3] x86/tdx: Fix one more load_unaligned_zeropad() issue Date: Tue, 6 Jun 2023 12:56:19 +0300 Message-Id: <20230606095622.1939-1-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org During review of TDX guests on Hyper-V patchset Dave pointed to the potential race between changing page private/shared status and load_unaligned_zeropad(). Fix the issue. v3: - Fix grammar; - Add Sathya's Reviewed-bys; v2: - Add more info in commit message of the first patch. - Move enc_status_change_finish_noop() into a separate patch. - Fix typo in commit message and comment. Kirill A. Shutemov (3): x86/mm: Allow guest.enc_status_change_prepare() to fail x86/tdx: Fix race between set_memory_encrypted() and load_unaligned_zeropad() x86/mm: Fix enc_status_change_finish_noop() arch/x86/coco/tdx/tdx.c | 64 +++++++++++++++++++++++++++++++-- arch/x86/include/asm/x86_init.h | 2 +- arch/x86/kernel/x86_init.c | 4 +-- arch/x86/mm/mem_encrypt_amd.c | 4 ++- arch/x86/mm/pat/set_memory.c | 3 +- 5 files changed, 69 insertions(+), 8 deletions(-) -- 2.39.3