Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp89047pxm; Tue, 1 Mar 2022 15:47:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPcUh/L/EN4B4ju51ffkhOrNKC85G/Z2+tiZXLjSXyY3uYVVoI1vmXAfr6Nqw8WSxNp14p X-Received: by 2002:a65:6d87:0:b0:374:2525:dcb0 with SMTP id bc7-20020a656d87000000b003742525dcb0mr24183930pgb.248.1646178475132; Tue, 01 Mar 2022 15:47:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646178475; cv=none; d=google.com; s=arc-20160816; b=V6NlrpIVd1AI7pLDMgS1gdicCyCUjUnh4cI3kVISZuBppzR2ZUBZhwlCK4SbQwyR0B 6Z1WZ9N0RK8TRB2umBvtToYxeut7ZikJoIAFW5Ucl/JIxKPkxWQq8EiMPbOjRBsKmv1+ lNq+7UA5w4ieaiXuHCUzbeTbE5e2h3DWS6g4k8KGBlhUNuB2kz6whTNgwwcaL7v5bzRO 3fn3OQ6oSDT91QkJz3+61+nYehlxjiIwBKIq21llcD3e3yWVQpl3a47qk4Vq4+iGJI3R aPElm/ckOCdvs3ZoPebjjDzSMRWvoa86H9zMaisN1odT8XJR18GNZXHfjdIhSDARmzLo nQ8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pqr3iNooD7nMEnAoRs9pCn3oSB7/Lnbl6Kcx/2eidGg=; b=cZo1esruWeVAv9fqNHCwBhm+5PgRwqeKVburPaVB8XfqrpPQ5DQCHi6MwsfLbuHkZz vnEgcE5AAF0YF50dpxWM3FGieYCMxIPmzkqHOJcScFYt4hLMBNreSiPXq6jXGZznCTp8 zJ9tjCIvzasJE+2jhgd+mh4uXq1CdQ0ohj20k7q9geLRhAruitneuIvCtufzO6iVsm7o k5a1DA1Td+O5hodI48Pny0Tl5IKrgxVnL+OuG9bXk61+F6+GSYcKdUU6axwBUFqwnpqa anNtmeitP3gvIDeMQeeukS2o8xfY/eV6zUZRlIEB/hkSBofCFbBOStRMcB4AFCEoHVIK 4lPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W3pA5syJ; 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=pass (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 c77-20020a624e50000000b004e10286cdb4si12711682pfb.245.2022.03.01.15.47.29; Tue, 01 Mar 2022 15:47:55 -0800 (PST) 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 header.s=Intel header.b=W3pA5syJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235823AbiCAPjq (ORCPT + 99 others); Tue, 1 Mar 2022 10:39:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235352AbiCAPjo (ORCPT ); Tue, 1 Mar 2022 10:39:44 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF492A9E24 for ; Tue, 1 Mar 2022 07:39:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646149143; x=1677685143; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=9B/nSIhnKpaShmw0MZ4KZdnrjCBOGcE0PdYVSUSa3e4=; b=W3pA5syJg6ZytglhDpIQUB0z0g0vg1Rmxgx9BPoNOb9IkP8/xbEfGUaP N2K8m45Dqo53K4PqVQqzmKG5Q2EsFTOFfrGlzi2hGP18ze8At2mz8oJM5 3gOLE3eJcL8bcONiex+s5BSq71vKjTQSOYKCxyjzp4o/s0MyJgzhVQhOk s4fjWXrVL3RapaLMAg78q+uHdrbQB8TToZMHY4RzaAg/f8LJ5mWQ7WXw/ Eu2JW9gR79fif9Rj1iidwUgoMcjdjQJ2X8OtL/g/hYgokg3oeQgakbjVg DJmbBpbyFS4B5RW4WkLEkYNyA7kTXy/TUs+oDnrhU1KqElAZ44fAT5P2m g==; X-IronPort-AV: E=McAfee;i="6200,9189,10272"; a="252889562" X-IronPort-AV: E=Sophos;i="5.90,146,1643702400"; d="scan'208";a="252889562" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2022 07:39:03 -0800 X-IronPort-AV: E=Sophos;i="5.90,146,1643702400"; d="scan'208";a="630050458" Received: from bklinvil-mobl.amr.corp.intel.com (HELO localhost) ([10.212.48.220]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Mar 2022 07:39:02 -0800 Date: Tue, 1 Mar 2022 07:39:02 -0800 From: Ira Weiny To: "Edgecombe, Rick P" Cc: "hpa@zytor.com" , "Williams, Dan J" , "dave.hansen@linux.intel.com" , "Yu, Fenghua" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH V8 30/44] mm/pkeys: Test setting a PKS key in a custom fault callback Message-ID: References: <20220127175505.851391-1-ira.weiny@intel.com> <20220127175505.851391-31-ira.weiny@intel.com> <20abc6a0b79e4fe9f60b16a1f3371f0676e77b82.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20abc6a0b79e4fe9f60b16a1f3371f0676e77b82.camel@intel.com> X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Mon, Jan 31, 2022 at 04:55:47PM -0800, Edgecombe, Rick P wrote: > On Thu, 2022-01-27 at 09:54 -0800, ira.weiny@intel.com wrote: > > Add a test which does this. > > > > $ echo 5 > /sys/kernel/debug/x86/run_pks > > $ cat /sys/kernel/debug/x86/run_pks > > PASS > > Hmm, when I run this on qemu TCG, I get: > > root@(none):/# echo 5 > /sys/kernel/debug/x86/run_pks > [ 29.438159] pks_test: Failed to see the callback > root@(none):/# cat /sys/kernel/debug/x86/run_pks > FAIL > > I think it's a problem with the test though. The generated code is not > expecting fault_callback_ctx.callback_seen to get changed in the > exception. The following fixed it for me: > > diff --git a/lib/pks/pks_test.c b/lib/pks/pks_test.c > index 1528df0bb283..d979d2afe921 100644 > --- a/lib/pks/pks_test.c > +++ b/lib/pks/pks_test.c > @@ -570,6 +570,7 @@ static bool run_fault_clear_test(void) > /* fault */ > memcpy(test_page, ctx->data, 8); > > + barrier(); > if (!fault_callback_ctx.callback_seen) { > pr_err("Failed to see the callback\n"); > rc = false; > > But, I wonder if volatile is also needed on the read to be fully > correct. I usually have to consult the docs when I deal with that > stuff... I was not able to reproduce this. However, I've done a lot of reading and I think you are correct that the barrier is needed. I thought WRITE_ONCE was sufficient and I had used it in other calls but I missed it here. As part of the test rework I've added a call to barrier() for all the tests. In addition I've simplified, and hopefully clarified, which variables are being shared with the fault handler. Thanks for the testing and review! Ira