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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A502C433E2 for ; Mon, 29 Mar 2021 22:10:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB7DA61989 for ; Mon, 29 Mar 2021 22:10:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231270AbhC2WKY (ORCPT ); Mon, 29 Mar 2021 18:10:24 -0400 Received: from mga17.intel.com ([192.55.52.151]:55738 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbhC2WJy (ORCPT ); Mon, 29 Mar 2021 18:09:54 -0400 IronPort-SDR: 1IyTQC/eh20gpBKQbi4p+CZpFc3ChcZ0v+vhj5N6NK/xTDVc5i51+DByfkyWhOjv7lqx1YGXbc xqt8PqOIdc3Q== X-IronPort-AV: E=McAfee;i="6000,8403,9938"; a="171651270" X-IronPort-AV: E=Sophos;i="5.81,289,1610438400"; d="scan'208";a="171651270" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 15:09:54 -0700 IronPort-SDR: yo4uthLS6800mpkglfqR1mZdGxCg+52HMiBWnGsQRmQjHqiO6MupQ9JuHHrf50g2fIV9OAhaH6 wn1EHDPW0OnA== X-IronPort-AV: E=Sophos;i="5.81,289,1610438400"; d="scan'208";a="444799334" Received: from ajzangar-mobl1.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.212.145.70]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 15:09:53 -0700 Subject: Re: [PATCH v2 1/1] x86/tdx: Handle MWAIT, MONITOR and WBINVD To: Dave Hansen , Peter Zijlstra , Andy Lutomirski Cc: Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Dan Williams , Raj Ashok , Sean Christopherson , linux-kernel@vger.kernel.org References: <91C0F6F1-B8C3-4130-B903-C63CD4B87F3F@amacapital.net> <498f078c-5196-a608-7f1a-8425ff056135@intel.com> <8e02ce39-f672-e652-b314-418b7ec5f52a@linux.intel.com> From: "Kuppuswamy, Sathyanarayanan" Message-ID: Date: Mon, 29 Mar 2021 15:09:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/29/21 3:02 PM, Dave Hansen wrote: > On 3/29/21 2:55 PM, Kuppuswamy, Sathyanarayanan wrote: >>> >>> MONITOR is a privileged instruction, right?  So we can only end up in >>> here if the kernel screws up and isn't reading CPUID correctly, right? >>> >>> That dosen't seem to me like something we want to suppress.  This needs >>> a warning, at least.  I assume that having a MONITOR instruction >>> immediately return doesn't do any harm. >> Agree. Since we are not supposed to come here, I will use BUG. > > "This is unexpected" is a WARN()able offense. > > "This is unexpected and might be corrupting data" is where we want to > use BUG(). > > Does broken MONITOR risk data corruption? We will be reaching this point only if something is buggy in kernel. I am not sure about impact of this buggy state. But MONITOR instruction by itself, should not cause data corruption. > >>>> +    case EXIT_REASON_MWAIT_INSTRUCTION: >>>> +        /* MWAIT is supressed, not supposed to reach here. */ >>>> +        WARN(1, "MWAIT unexpected #VE Exception\n"); >>>> +        return -EFAULT; >>> >>> How is MWAIT "supppressed"? >> I am clearing the MWAIT feature flag in early init code. We should also >> disable this feature in firmware. setup_clear_cpu_cap(X86_FEATURE_MWAIT); > > I'd be more explicit about that. Maybe even reference the code that > clears the X86_FEATURE. This change is part of the same patch. > -- Sathyanarayanan Kuppuswamy Linux Kernel Developer