Received: by 2002:a05:6a10:e90b:0:0:0:0 with SMTP id gt11csp4493916pxb; Tue, 6 Apr 2021 13:08:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycsSsTTCDcogCdcnVDGoxyR7lgHJQWOLm4434HOUUD150+BsWFtn6xPum7ZSzmnfz2V+Xk X-Received: by 2002:a17:906:6b8c:: with SMTP id l12mr1947993ejr.511.1617739712745; Tue, 06 Apr 2021 13:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617739712; cv=none; d=google.com; s=arc-20160816; b=TTbaNMO0sqVskWM3xlMfTF3FaZB6hVE5vnU+qjXzpd2H2WyT44pxw24+R2qSddN+Jn qzo79PzQyGA2Vp9vkIsA5QoaS7V9s2Reujd3Mpa64cGjDFUx5f3Hnltt98W1JOKu3BSW UGvGzu2M8SGlJraVupgSZWJt2EccCNxzrtn3UMyoBR2YpTmd0ZBKuyVL7zBcbvDdBrgU tPIHXtAnEkS60Jmerg9QNMUHZVKvYzyHZUnsT6O7SWa+OcezA47h0050IJEP8ZjW1gg3 rH2LHjUv9K3byUCYUep4mqy1VkE9xxGcY5DfZFuo+91SFPFeHsAji5AsdCgaA+byi+k6 pk3w== 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:ironport-sdr :ironport-sdr; bh=RgmniH97/0NBfv1CglAL+tv1aXyr4ydgHUv29GqI2vI=; b=N3t/z62233Ds43qk9Ymw0zI1o3yLjPkvxhz5ZWKtN59m7IZAKfOzhjLmmF8ps+k01H 8MOyOSMyXNRr1iBPayW9jPPjX5jILfGIYH3WU9vhTcXZvFocKuMkfXZLGG2v4wLZE7Fi 1P1sVoyUtGUzdkJhWrAvCqPhX0cqgvq9dcbsVjNX7BhaOIwQO7Y4GUdcVEllNBUj1QJY KuuFdWJU6xmsvtn/AsFGpgMukQbWCQ156AUMepvGtl/61hlaApUSMG9awvFm9js+u3qo uFU3QqJXptKIrQe2mfIjGi57LWzvKAmH5r6JC36Vzysd5B22URcvv39Y6l6lIf+pbWVR 8aHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x12si16174932edd.423.2021.04.06.13.07.38; Tue, 06 Apr 2021 13:08:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245193AbhDFKuc (ORCPT + 99 others); Tue, 6 Apr 2021 06:50:32 -0400 Received: from mga03.intel.com ([134.134.136.65]:36682 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242695AbhDFKu3 (ORCPT ); Tue, 6 Apr 2021 06:50:29 -0400 IronPort-SDR: eyEVuMdzHhPeiMFjex/7+UsIr2Jp/OGJxt6rCGD2Aa7wJmTn+ItZyGT/2iZaQZmQ1lFi6qdaZs DkHHKPPK97oA== X-IronPort-AV: E=McAfee;i="6000,8403,9945"; a="193079682" X-IronPort-AV: E=Sophos;i="5.81,309,1610438400"; d="scan'208";a="193079682" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2021 03:50:21 -0700 IronPort-SDR: 8/Y2cr+OADla4TLlnAo6H5OCCTBNzsA8FTkB09gdeAgSuSL4k7U5bXGW5oOw1M/hz7Yw5EhgYD Y9x0mvzOWZuw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,309,1610438400"; d="scan'208";a="386530847" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 06 Apr 2021 03:50:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id A3A4629D; Tue, 6 Apr 2021 13:50:24 +0300 (EEST) Date: Tue, 6 Apr 2021 13:50:24 +0300 From: "Kirill A. Shutemov" To: David Hildenbrand Cc: "Kirill A. Shutemov" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Sean Christopherson , Jim Mattson , David Rientjes , "Edgecombe, Rick P" , "Kleen, Andi" , "Yamahata, Isaku" , x86@kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RFCv1 7/7] KVM: unmap guest memory using poisoned pages Message-ID: <20210406105024.ikz5fbozwu476yba@black.fi.intel.com> References: <20210402152645.26680-1-kirill.shutemov@linux.intel.com> <20210402152645.26680-8-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 06, 2021 at 09:44:07AM +0200, David Hildenbrand wrote: > On 02.04.21 17:26, Kirill A. Shutemov wrote: > > TDX architecture aims to provide resiliency against confidentiality and > > integrity attacks. Towards this goal, the TDX architecture helps enforce > > the enabling of memory integrity for all TD-private memory. > > > > The CPU memory controller computes the integrity check value (MAC) for > > the data (cache line) during writes, and it stores the MAC with the > > memory as meta-data. A 28-bit MAC is stored in the ECC bits. > > > > Checking of memory integrity is performed during memory reads. If > > integrity check fails, CPU poisones cache line. > > > > On a subsequent consumption (read) of the poisoned data by software, > > there are two possible scenarios: > > > > - Core determines that the execution can continue and it treats > > poison with exception semantics signaled as a #MCE > > > > - Core determines execution cannot continue,and it does an unbreakable > > shutdown > > > > For more details, see Chapter 14 of Intel TDX Module EAS[1] > > > > As some of integrity check failures may lead to system shutdown host > > kernel must not allow any writes to TD-private memory. This requirment > > clashes with KVM design: KVM expects the guest memory to be mapped into > > host userspace (e.g. QEMU). > > So what you are saying is that if QEMU would write to such memory, it could > crash the kernel? What a broken design. Cannot disagree. #MCE for integrity check is very questionable. But I'm not CPU engineer. > "As some of integrity check failures may lead to system shutdown host" -- > usually we expect to recover from an MCE by killing the affected process, > which would be the right thing to do here. In the most cases that's what happen. > How can it happen that "Core determines execution cannot continue,and it > does an unbreakable shutdown". Who is "Core"? CPU "core", MM "core" ? CPU core. > And why would it decide to do a shutdown instead of just killing the > process? If the CPU handles long flow instruction (involves microcode and doing multiple memory accesses), consuming poison somewhere in the middle leads to CPU not being able to get back into sane state and the only option is system shutdown. -- Kirill A. Shutemov