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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C736AC433EF for ; Thu, 14 Oct 2021 02:21:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A382D611CA for ; Thu, 14 Oct 2021 02:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229966AbhJNCXd (ORCPT ); Wed, 13 Oct 2021 22:23:33 -0400 Received: from mga02.intel.com ([134.134.136.20]:47432 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229837AbhJNCXc (ORCPT ); Wed, 13 Oct 2021 22:23:32 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10136"; a="214740311" X-IronPort-AV: E=Sophos;i="5.85,371,1624345200"; d="scan'208";a="214740311" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2021 19:21:27 -0700 X-IronPort-AV: E=Sophos;i="5.85,371,1624345200"; d="scan'208";a="487166779" Received: from dravindr-mobl.amr.corp.intel.com (HELO skuppusw-desk1.amr.corp.intel.com) ([10.254.11.40]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2021 19:21:26 -0700 Subject: Re: [PATCH v7 6/6] x86/split_lock: Fix the split lock #AC handling when running as guest To: Xiaoyao Li , Sean Christopherson , Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, Paolo Bonzini , David Hildenbrand , Andrea Arcangeli , Josh Poimboeuf , "H . Peter Anvin" , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , linux-kernel@vger.kernel.org References: <20211005230550.1819406-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20211005230550.1819406-7-sathyanarayanan.kuppuswamy@linux.intel.com> <38a70cf2-1849-97fd-82a2-10ce64c6be8c@linux.intel.com> <71884ac9-6da3-e75d-af1e-f8f24a7562cb@intel.com> From: Sathyanarayanan Kuppuswamy Message-ID: Date: Wed, 13 Oct 2021 19:21:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <71884ac9-6da3-e75d-af1e-f8f24a7562cb@intel.com> 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 10/13/21 6:24 PM, Xiaoyao Li wrote: > On 10/14/2021 5:32 AM, Sathyanarayanan Kuppuswamy wrote: >> + Xiaoyao >> >> On 10/13/21 1:30 PM, Sean Christopherson wrote: >>> On Tue, Oct 05, 2021, Kuppuswamy Sathyanarayanan wrote: >>>> From: Xiaoyao Li >>>> >>>> If running as guest and hypervisor enables >>>> MSR_TEST_CTRL.SPLIT_LOCK_DETECT during its running, it can get split >>>> lock #AC even though sld_state is sld_off. >>> That's a hypervisor bug, no?  The hypervisor should never inject a >>> fault that >>> the guest cannot reasonably expect. > > What if hypervisor doesn't intercept #AC and host enables > SPLIT_LOCK_DETECT during guest running? That's exactly the case TDX is > facing. > > (BTW, this patch is not complete that no matter what state sld_state > is, it should always treat it as fatal even sld_warn because sld_warn > doesn't guarantee SPLIT_LOCK_DETECT is available) > > Sathya, we need to drop this one. Andi has anther one to disable split > lock detection for SPR. That's a better direction. Ok. I will fix this in next submission. > >>>> For kernel mode #AC, it always dies("split lock"), no more action >>>> needed. >>>> >>>> For user mode #AC, it should treat sld_off (default state when feature >>>> is not available) as fatal as well. >>>> >>>> Signed-off-by: Xiaoyao Li >>>> Signed-off-by: Kuppuswamy Sathyanarayanan >>>> >>>> --- >>>>   arch/x86/kernel/cpu/intel.c | 7 ++++++- >>>>   1 file changed, 6 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c >>>> index 01d7935feaed..47f0bc95ce2a 100644 >>>> --- a/arch/x86/kernel/cpu/intel.c >>>> +++ b/arch/x86/kernel/cpu/intel.c >>>> @@ -1190,7 +1190,12 @@ static void bus_lock_init(void) >>>>   bool handle_user_split_lock(struct pt_regs *regs, long error_code) >>>>   { >>>> -    if ((regs->flags & X86_EFLAGS_AC) || sld_state == sld_fatal) >>>> +    /* >>>> +     * In virtualization environment, it can get split lock #AC >>>> even when >>>> +     * sld_off but hypervisor enables it. >>>> +     * Thus only handles when sld_warn explicitly. >>>> +     */ >>>> +    if ((regs->flags & X86_EFLAGS_AC) || sld_state != sld_warn) >>>>           return false; >>>>       split_lock_warn(regs->ip); >>>>       return true; >>>> -- >>>> 2.25.1 >>>> > -- Sathyanarayanan Kuppuswamy Linux Kernel Developer