Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp181269pxb; Thu, 14 Apr 2022 19:26:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnqawNPX5SSbQvCWXtAVyO/jaPtJXTzRWFyglnWmp4+JzhE5stnCy6iMzl8+JrNBXOScdB X-Received: by 2002:a17:907:1611:b0:6ef:5d92:5941 with SMTP id hb17-20020a170907161100b006ef5d925941mr80857ejc.10.1649989574385; Thu, 14 Apr 2022 19:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649989574; cv=none; d=google.com; s=arc-20160816; b=vi5ezRAjFQP0S4TNH9dcyXORynxHg3b8NbMx/8wrvsBy+kc9IfUJxsmb2jv/St2UG9 8Xb9Ee1K/xzJZc7DsYiDvqYDLrwAM+XnEiZB4d+mQ59jy7DlrdNjiH+O/dA5t8rmGkoH J/QYhK0UBYyTseDymVjApY4I21TIhPut9SgarHR/QW+N9zVRJ2dqotlFxKwK63ydkYha Vy5jlnRSLWhtYLBr2kl9mBUPTKxz5JKmuvnbyOREsghrQRWkzEcvBIrKzCgqIdKGE8CX 0oUhzAiQt22Hh3uGLAE62EBB8ifyXR/T6J1QfVB3+HnidsuQqQdUPg7lTUNef1hC23Er LnUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YSNIpToEpKx9C/PikZnCWZV0FikRekKMo16pPMd1DpA=; b=M6Ch9PIQV//gt6D5qwcAHVLpLQ9q6hIztu117w1rrV5WlPUdprrNdZ8m1c3HpwQ4tc khqvG5YNQTqkEYHDMkEu+EyHL5axBS1G8WxdqQqtV4UpR7bhUTmt7ut0Gtm0s/TJB4uG MMOV2sbxNNXG/hxwrOlAkO9L4cOl//ea0r+kskXsGSOA0diHZ16mL8EMq1XHsPcx6+uF a68qfUAxwT1aV/JPmY7G90mgg5VE+NdT/MHLCGQmCE76n/2Rw5EYoq41DmxlsbnRcBSE FWZ3vsSMd/fsoEJFO2Dd6bti6Hzk17pXKNaHbTU+XNsD0aCyszFMg6NDDhBz5c0q2PAf sQAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20210112.gappssmtp.com header.s=20210112 header.b=LGvyFYmB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a056402084900b0041d7b14dd07si273890edz.224.2022.04.14.19.25.47; Thu, 14 Apr 2022 19:26:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20210112.gappssmtp.com header.s=20210112 header.b=LGvyFYmB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239496AbiDNCfZ (ORCPT + 99 others); Wed, 13 Apr 2022 22:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239505AbiDNCfX (ORCPT ); Wed, 13 Apr 2022 22:35:23 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24CAB53724 for ; Wed, 13 Apr 2022 19:32:59 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id q12so3513193pgj.13 for ; Wed, 13 Apr 2022 19:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YSNIpToEpKx9C/PikZnCWZV0FikRekKMo16pPMd1DpA=; b=LGvyFYmBi//2J872dwC4BWvIgavMY42bnfS/6eXxFjyQAxgAIQmx/fj2cZ5NGgLQJ0 Vj71Y/5rxksooccCGRxuVyYKJy0Vi/ysD/idUzToiZUWPz9xP526Vjd43hTc3P20brja hMzCaQeubXgiZec4rGfcnX6iqTHx06cDAqA4Xh7ssUrCqd9mXR9fnvZnt4QoZ2Se3lPk g8nY1MnrV2CVGmaTfsV8k2bQAGmQUpjHcwKEvQx8Hn+kYp3uV3prZLcy/41Qt2+ZWt50 +GDObPXKuVEPcRlyzFFyTzZOxPL2HWNMJvafbWCfk6g4HkMqj9uHEcPDlsqjpetzgtnW IZng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YSNIpToEpKx9C/PikZnCWZV0FikRekKMo16pPMd1DpA=; b=VXgUVApO8bAikPLbG9HMLLAZqABD/AjM78lDhO0sIHvsd4Z58kAbm4CIJIsIwXTSJ6 fAUSXPUlZBxgc26pXxSwyIeT1vF50TZVfMeDWYSO7odk9SgeyVKGuRLYIUTabXH2DiAM +sP9ukxobXKd9sSHI7yruDKG8BPrTdz4GSEOt715KO0+d2uxBw4cuwENMHABTGN4m4Y6 oSWV7xS7fevgA8OZCvk93g5TRZR+Knuc1kmVTEvgeN/T36uZugXvEEl35pgoAf7g+euT JgwxDKnM2sVocTk1xrLowNTcQmho8qEHxLTO7r6XTZvVaSj2Q4f0su2+pnh1HAPFWhfQ lTbg== X-Gm-Message-State: AOAM531RHZSasRLXxnM6Jzdwkq9EbNnJZQEFc7rDqSAWWkKNlu2NMdus 0TvCop1Y9QrSXgNdmD9TOxDbZND2qcIhfFNuOZ5mRg== X-Received: by 2002:a05:6a02:283:b0:342:703e:1434 with SMTP id bk3-20020a056a02028300b00342703e1434mr522640pgb.74.1649903578582; Wed, 13 Apr 2022 19:32:58 -0700 (PDT) MIME-Version: 1.0 References: <20220405194747.2386619-1-jane.chu@oracle.com> <20220405194747.2386619-4-jane.chu@oracle.com> In-Reply-To: From: Dan Williams Date: Wed, 13 Apr 2022 19:32:47 -0700 Message-ID: Subject: Re: [PATCH v7 3/6] mce: fix set_mce_nospec to always unmap the whole page To: Jane Chu Cc: david , "Darrick J. Wong" , Christoph Hellwig , Vishal L Verma , Dave Jiang , Alasdair Kergon , Mike Snitzer , device-mapper development , "Weiny, Ira" , Matthew Wilcox , Vivek Goyal , linux-fsdevel , Linux NVDIMM , Linux Kernel Mailing List , linux-xfs , X86 ML , "luto@kernel.org" , "peterz@infradead.org" , "dave.hansen@intel.com" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 13, 2022 at 4:36 PM Jane Chu wrote: > > On 4/11/2022 4:27 PM, Dan Williams wrote: > > On Tue, Apr 5, 2022 at 12:48 PM Jane Chu wrote: > >> > >> The set_memory_uc() approach doesn't work well in all cases. > >> For example, when "The VMM unmapped the bad page from guest > >> physical space and passed the machine check to the guest." > >> "The guest gets virtual #MC on an access to that page. > >> When the guest tries to do set_memory_uc() and instructs > >> cpa_flush() to do clean caches that results in taking another > >> fault / exception perhaps because the VMM unmapped the page > >> from the guest." > >> > >> Since the driver has special knowledge to handle NP or UC, > > > > I think a patch is needed before this one to make this statement true? I.e.: > > > > diff --git a/drivers/acpi/nfit/mce.c b/drivers/acpi/nfit/mce.c > > index ee8d9973f60b..11641f55025a 100644 > > --- a/drivers/acpi/nfit/mce.c > > +++ b/drivers/acpi/nfit/mce.c > > @@ -32,6 +32,7 @@ static int nfit_handle_mce(struct notifier_block > > *nb, unsigned long val, > > */ > > mutex_lock(&acpi_desc_lock); > > list_for_each_entry(acpi_desc, &acpi_descs, list) { > > + unsigned int align = 1UL << MCI_MISC_ADDR_LSB(mce->misc); > > struct device *dev = acpi_desc->dev; > > int found_match = 0; > > > > @@ -63,8 +64,7 @@ static int nfit_handle_mce(struct notifier_block > > *nb, unsigned long val, > > > > /* If this fails due to an -ENOMEM, there is little we can do */ > > nvdimm_bus_add_badrange(acpi_desc->nvdimm_bus, > > - ALIGN(mce->addr, L1_CACHE_BYTES), > > - L1_CACHE_BYTES); > > + ALIGN(mce->addr, align), align); > > nvdimm_region_notify(nfit_spa->nd_region, > > NVDIMM_REVALIDATE_POISON); > > > > Dan, I tried the above change, and this is what I got after injecting 8 > back-to-back poisons, then read them and received SIGBUS/BUS_MCEERR_AR, > then repair via the v7 patch which works until this change is added. > > [ 6240.955331] nfit ACPI0012:00: XXX, align = 100 > [ 6240.960300] nfit ACPI0012:00: XXX, ALIGN(mce->addr, > L1_CACHE_BYTES)=1851600400, L1_CACHE_BYTES=40, ALIGN(mce->addr, > align)=1851600400 > [..] > [ 6242.052277] nfit ACPI0012:00: XXX, align = 100 > [ 6242.057243] nfit ACPI0012:00: XXX, ALIGN(mce->addr, > L1_CACHE_BYTES)=1851601000, L1_CACHE_BYTES=40, ALIGN(mce->addr, > align)=1851601000 > [..] > [ 6244.917198] nfit ACPI0012:00: XXX, align = 1000 > [ 6244.922258] nfit ACPI0012:00: XXX, ALIGN(mce->addr, > L1_CACHE_BYTES)=1851601200, L1_CACHE_BYTES=40, ALIGN(mce->addr, > align)=1851602000 > [..] > > All 8 poisons remain uncleared. > > Without further investigation, I don't know why the failure. > Could we mark this change to a follow-on task? Perhaps a bit more debug before kicking this can down the road... I'm worried that this means that the driver is not accurately tracking poison data For example, that last case the hardware is indicating a full page clobber, but the old code would only track poison from 1851601200 to 1851601400 (i.e. the first 512 bytes from the base error address). Oh... wait, I think there is a second bug here, that ALIGN should be ALIGN_DOWN(). Does this restore the result you expect? diff --git a/drivers/acpi/nfit/mce.c b/drivers/acpi/nfit/mce.c index ee8d9973f60b..d7a52238a741 100644 --- a/drivers/acpi/nfit/mce.c +++ b/drivers/acpi/nfit/mce.c @@ -63,8 +63,7 @@ static int nfit_handle_mce(struct notifier_block *nb, unsigned long val, /* If this fails due to an -ENOMEM, there is little we can do */ nvdimm_bus_add_badrange(acpi_desc->nvdimm_bus, - ALIGN(mce->addr, L1_CACHE_BYTES), - L1_CACHE_BYTES); + ALIGN_DOWN(mce->addr, align), align); nvdimm_region_notify(nfit_spa->nd_region, NVDIMM_REVALIDATE_POISON); > The driver knows a lot about how to clear poisons besides hardcoding > poison alignment to 0x40 bytes. It does, but the badblocks tracking should still be reliable, and if it's not reliable I expect there are cases where recovery_write() will not be triggered because the driver will not fail the dax_direct_access() attempt.