From mboxrd@z Thu Jan 1 00:00:00 1970 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A89E3EB64D9 for ; Thu, 29 Jun 2023 11:22:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FB8F8D0003; Thu, 29 Jun 2023 07:22:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2ABC18D0001; Thu, 29 Jun 2023 07:22:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14CB58D0003; Thu, 29 Jun 2023 07:22:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 048308D0001 for ; Thu, 29 Jun 2023 07:22:16 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C58C9160DE9 for ; Thu, 29 Jun 2023 11:22:15 +0000 (UTC) X-FDA: 80955546630.17.7F7F16A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 76A184001A for ; Thu, 29 Jun 2023 11:22:13 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FnQzI8cL; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688037733; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EdhcgbMrVqcwBO72p4YdB+Tlm3/fEdhj6DWO3Cu42oI=; b=PX5PS8/jhgtxfbxu7AHG0s36wU27Fy+WYM9OTUq3sS2/+umoNC6tyzvKyuRap/Z4t1AKDf o7TQy9y+DCNLABGRUK8MocEN+WxUL6HqmKnaFa4XLS0A55yBTsm68AfE9ZfzOug4rDUeNP 7gNlGOa7/4tbxhEwSBKbobSUMhy0sTg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688037733; a=rsa-sha256; cv=none; b=cLxZLkxHTi36MqtNlrOTGtlGN5jnnLWlURAby6mWzCZneuOglpRSmWbwVQddmifZbl1Ldn T/ErZitbUUMRH2yPGmemfK63crV9u3USCQGwZ8dcyXN/1kA0vwDupMNv/KvW+lLJm/mX7x bAg7L36WBIZeH+gZ+LVEOpsLKbOx+yw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FnQzI8cL; spf=pass (imf07.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688037732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EdhcgbMrVqcwBO72p4YdB+Tlm3/fEdhj6DWO3Cu42oI=; b=FnQzI8cLdWZChOcp1YgwpdOaUJe9wpdy3PMfUK0KvCindF2762toBBEiRUzIutjAoiR4Fb wbBTXyVoGp6k+nJnvK9/1pjTAW8jcp8FR919qS+gGo72bjAhOAz/9a7aNejsHUH4IlZCg4 o/fd90Hrkuv5ki8w+Xide+2WPW1xvQs= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-6ufcX13uOEy8nutx0eZ9Vw-1; Thu, 29 Jun 2023 07:22:11 -0400 X-MC-Unique: 6ufcX13uOEy8nutx0eZ9Vw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fa871e1eaaso8629275e9.3 for ; Thu, 29 Jun 2023 04:22:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688037730; x=1690629730; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EdhcgbMrVqcwBO72p4YdB+Tlm3/fEdhj6DWO3Cu42oI=; b=Fqy9hlkGWdsYM77Xt8B9SD0Ml7b1D6rJEiEYBNopnFYwkneScoV2Rzr3iPxlz6zEEy +h/qXF7NzlP0JLtzffI3OWDJmE6M929ef9LZYrQQfPInacPydBdwrmBfWw/uKC4TCIaP QffWdjnWHUV95UGKhkUVVUxbbQIJAKZ1a6/bnxAcVHa2ANv5Iw47/VF+OC3s03D+GPSu CyeS1mhv5aiAgOXKRxArLpXH0TRTDcSs+2X6SshZn/V7Qrnarmpy7q8gLKmmKEmGw34H Fs/Za5ZTsjFS2pfCm93blgpeWu4me5xyFx/irvrI6uzE/no9Y4U5VVTUE0vZztwoKnyH 3tgA== X-Gm-Message-State: AC+VfDx/K0QWayj2XDH0nHre5twOv1gIY5bvfviTXzy018Tw7Ho4JL+d 2zYBjxgduWJOZU+ZJqBlAHj+IiNrSujksVVnDpV2pH3OrpDNECIC256ZwaFfROdjjGvynptmkUN 0JI5g38kWb+o= X-Received: by 2002:a05:600c:2041:b0:3fb:9ef1:34ef with SMTP id p1-20020a05600c204100b003fb9ef134efmr9178949wmg.37.1688037730305; Thu, 29 Jun 2023 04:22:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wqwgjIqNoVKiMHXKOfrLuvRz9SMghs4Sk6YyXQuWFdCux2FfsbPa2XdfcbUoqSB1b1YT5rg== X-Received: by 2002:a05:600c:2041:b0:3fb:9ef1:34ef with SMTP id p1-20020a05600c204100b003fb9ef134efmr9178909wmg.37.1688037729942; Thu, 29 Jun 2023 04:22:09 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id y19-20020a05600c365300b003fa8dbb7b5dsm12475267wmq.25.2023.06.29.04.22.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jun 2023 04:22:09 -0700 (PDT) Message-ID: Date: Thu, 29 Jun 2023 13:22:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v12 04/22] x86/cpu: Detect TDX partial write machine check erratum To: Kai Huang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, dave.hansen@intel.com, kirill.shutemov@linux.intel.com, tony.luck@intel.com, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de, mingo@redhat.com, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, dan.j.williams@intel.com, rafael.j.wysocki@intel.com, ashok.raj@intel.com, reinette.chatre@intel.com, len.brown@intel.com, ak@linux.intel.com, isaku.yamahata@intel.com, ying.huang@intel.com, chao.gao@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, nik.borisov@suse.com, bagasdotme@gmail.com, sagis@google.com, imammedo@redhat.com References: <0f701502157029989617bcb3f5940ff48e19a2b2.1687784645.git.kai.huang@intel.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: <0f701502157029989617bcb3f5940ff48e19a2b2.1687784645.git.kai.huang@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 76A184001A X-Rspam-User: X-Stat-Signature: 9yci38zdd71j7c386nsctwgpk1fszgqw X-Rspamd-Server: rspam03 X-HE-Tag: 1688037733-309454 X-HE-Meta: U2FsdGVkX1+nLTFiv/9sYB48T/DJUaJbCjBBQx1lC9w2oJCZEos7BHXUgnqPrIp1/bolzGelsTllDb6WqU/dJc4yBESImgr7yGsjK1qVgVniv4m9SlP8PqwuGECwY0EUxhcUKO8/xw65dz9IHukHxvJtsITnq3FoGKFE0VmGif1+bulObQWPBxWctscph84NTSEh5hRI+7tmDFxSi9NhvaSuUpPmqNLDcPW/+C1jE9fPJaGz8BScXbE6LkYUnKtzNdq7VdsJH12Sqyaj6cZbB0PTL2s8S4/ZAeheiaMuekgqLv5zvnWTIcNbOs8r9YBhG+3iO22xICi5j2fRcK3hy7AoxJIYMToZHpxUKlbmO2jCTfWZxM6DR0ulmjphEF1SpoJso5+gxmpvo7Dx8rrfnJF7eZNZg+BkQ4gl9ZA5tbGc/BQoyZryfkWrZLPrtoq3DprpqfKRbHWvCIOmVcn/Uhywzh5tUPrC0IEGYhD17oLxx51S8UPnw3MOiVfXKu83hcnJhDlOOXjzxVPnP4tfJQ2jjFEr3C3RjqtsxUrFersAjophDDTscyJkpMQ7MAvzdK4Kh1nIhzrTCnATn5Tx7KAlVaIUFpjzU5lOPjcZ7yJUo77spZaP5dgnrepJZP9t+l6qRZBsDYVWGs2pKen3hXOnCXYijgHlTlE2A2YBINPUsfZUvBKG7HYaEiYhmc/RQlWHCaaJVzai4MDrxaw2oMeq0pz4DKcXWQQqoPADowE+yehUASU/Y09yQCTe3CnQ70gABLBE+A7R4at8fRhE/PMLNQAVWH799gE2Y/4dSHZfWXZLM04evstaQYm8tSFqNvsqL3Ef3Kyf7zScqNAbtTNdTIVuY48r4c07VGEn4DTpoQ0xn1UnkQtFIEG+ydfS277cdzFnVbQKGa6e2GMpDk8vZWJj+PsraWN1RFgPTIu3BATMwCoayq8dnld/UCb7ANQhBEwAUk+diHHuqdP NQTaxxzc PqoZeRFf1iUcdQTOfUj/pNwifr7zzSJGd+1wxI9C3SFpYcI7kljF+lNZCRubNNz8Hsp0WZ1OUL89qzL4C6n+EBIGQ2k8MaBOsb2/bGygWrJo4eD4TMzT2iqu8jdxEmLF20X56Mp++YW+gzYCwvlQzfZkZglGIFHfNoCu9XlTVaajYzmcnQk83PD+MRKan2NzPacavH/fMRC2mlR81RiUgq/47EskccADrN8TXA1X7YLmAjCq3DCJEfZ4YoYLPpX1a4g3XgxWQiQDXeEMmLfs76cQbpUpyPslnRsKygffT8U7VUVyTAnmbS/VKajeHFAL4JfoXQ1jjEHd3X4LOZ/xioPQWgDT6+QRCKCSwpV/wcrDsb0KgWhnvs10tFdxZXqKQDeNrc6vfX0ovUg6h45I7YBdVbyAXKLCTiR9G3v+K58vI2e6HIwTiZQCrew4toScLa4V2lKZ/pfqR8JY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 26.06.23 16:12, Kai Huang wrote: > TDX memory has integrity and confidentiality protections. Violations of > this integrity protection are supposed to only affect TDX operations and > are never supposed to affect the host kernel itself. In other words, > the host kernel should never, itself, see machine checks induced by the > TDX integrity hardware. > > Alas, the first few generations of TDX hardware have an erratum. A > partial write to a TDX private memory cacheline will silently "poison" > the line. Subsequent reads will consume the poison and generate a > machine check. According to the TDX hardware spec, neither of these > things should have happened. > > Virtually all kernel memory accesses operations happen in full > cachelines. In practice, writing a "byte" of memory usually reads a 64 > byte cacheline of memory, modifies it, then writes the whole line back. > Those operations do not trigger this problem. > > This problem is triggered by "partial" writes where a write transaction > of less than cacheline lands at the memory controller. The CPU does > these via non-temporal write instructions (like MOVNTI), or through > UC/WC memory mappings. The issue can also be triggered away from the > CPU by devices doing partial writes via DMA. > > With this erratum, there are additional things need to be done. Similar > to other CPU bugs, use a CPU bug bit to indicate this erratum, and > detect this erratum during early boot. Note this bug reflects the > hardware thus it is detected regardless of whether the kernel is built > with TDX support or not. > > Signed-off-by: Kai Huang > Reviewed-by: Kirill A. Shutemov > --- Reviewed-by: David Hildenbrand -- Cheers, David / dhildenb