Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1685925pxj; Wed, 19 May 2021 11:26:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzf2tLYdHytgCi7bpXr43RMfXMrw7irIucFvvIRkBrNlhGvPuYDFYJmFkQve38NczsjOdbN X-Received: by 2002:aa7:cc10:: with SMTP id q16mr403739edt.53.1621448817302; Wed, 19 May 2021 11:26:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621448817; cv=none; d=google.com; s=arc-20160816; b=RQweDAuxuHHJUqbDEmNGbMYcp8aYw5QOty/MUQaUXYxvwcVw7ynVc7P4F3DAJ3J0xf AHxBGE7dphgMX3kR5vrBrOeyiZ6N1WdZffBC1cbB9UtofcLLxX5w9iqDHx0WZiLCEpax HGSFF+kB6TgCMk+NUtUfus1rny34SsAW2fhavNKD3VJLaNSbuCAjVisv/ubC6Elu4/LT ZVSG2/IlKwatKLMMOxhly8TaXjkVBFcRfJZJ0zAEmunNSikz7T7/RHXg/4ryGjJaCQnJ TXaMuLJwjwh803lofTB+Dh51HonjxOwnVutws3837m/hBcgWGf1DkqwGJJ+h1wETld8V W+ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject:ironport-sdr:ironport-sdr; bh=8cnWqqfhHJxIC+k93tJ/u63UbgoNE3Hr/2zNT+1O6dE=; b=LDJcZ+y+P9kszNZhPBYi+SyGu9KXnl8hE8zAg28Zu7qzXdQ1YTZJi7zPq77YPztOPZ g534i8yOJsfYM8rky0qgxpfaAmC4j1eN/bOniA6wUejPgXviDoEf1VJ0ia0wiR9F3JNN 69UYCdrF3DHkSQLxKejbTE2QorrOzMF2jluga2vNukxXegFCy3d7XLzkKTljCI5Lm0WJ X6ClB++vz7n15yvkacphREoWRIixZlwqZtQxb0ZToj8wO6MF8HgFtDFwFHquQXYf1rJL VOo81mdYZ/XkuZ23gaTcOk/aCZzPrH7t83F8oBUTdhyTFU/S+HZ+m2I4LGUYCB1+5KDH wnxg== 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 m12si8018508edr.335.2021.05.19.11.26.10; Wed, 19 May 2021 11:26:57 -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 S1351111AbhERR3U (ORCPT + 99 others); Tue, 18 May 2021 13:29:20 -0400 Received: from mga03.intel.com ([134.134.136.65]:21213 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351129AbhERR3U (ORCPT ); Tue, 18 May 2021 13:29:20 -0400 IronPort-SDR: lUob1hYAOZ7oRnit9ikS1OcM1338DxmU3xVowpPmteEkkGUTX5SE9hD5mWAxQO7UkEECZSFiH6 9KTvybhb0F/g== X-IronPort-AV: E=McAfee;i="6200,9189,9988"; a="200826730" X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="200826730" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 10:28:01 -0700 IronPort-SDR: jFrZ9cGVo6RbkPKXe5TRhoN+XDajbUVbCBa4omSA9oz9rO5fnw8PzK4j0FiASIESg1KVX0zze3 RYwXubFKy0tA== X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="439535045" Received: from akleen-mobl1.amr.corp.intel.com (HELO [10.209.65.183]) ([10.209.65.183]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 10:28:01 -0700 Subject: Re: [RFC v2-fix 1/1] x86/tdx: Handle in-kernel MMIO From: Andi Kleen To: Dave Hansen , Kuppuswamy Sathyanarayanan , Peter Zijlstra , Andy Lutomirski Cc: Tony Luck , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Dan Williams , Raj Ashok , Sean Christopherson , linux-kernel@vger.kernel.org References: <3e9a26c3-8eee-88f5-f8e2-8a2dd2c028ea@intel.com> <20210518004807.258503-1-sathyanarayanan.kuppuswamy@linux.intel.com> <36cd2665-6d8b-9c0b-eec1-25152dcca2a3@intel.com> <43e583a3-ee2b-52d8-5275-e26a6609c126@linux.intel.com> <94dc5a5a-8c51-8624-5810-e6278783789c@intel.com> Message-ID: Date: Tue, 18 May 2021 10:28:00 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/18/2021 9:10 AM, Andi Kleen wrote: > >>>>> For now we only handle a subset of instructions that the kernel >>>>> uses for MMIO operations. User-space access triggers SIGBUS. >>>> How do you know which instructions the kernel uses? >>> They're all in MMIO macros. >> I've heard exactly the opposite from the TDX team in the past. What I >> remember was a claim that one can not just leverage the MMIO macros as a >> single point to avoid MMIO.  I remember being told that not all code in >> the kernel that does MMIO uses these macros.  APIC MMIO's were called >> out as a place that does not use the MMIO macros. > > Yes x86 APIC has its own macros, but we don't use the MMIO based APIC, > only X2APIC in TDX. I must correct myself here. We actually use #VE to handle MSRs, or at least those that are not context switched by the TDX module. So there can be #VE nested in NMI in normal operation, since MSR accesses in NMI can happen. I don't think it needs any changes to the code -- this should all work -- but we need to update the commit log to document this case. -Andi