Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1022717pxb; Thu, 17 Feb 2022 21:51:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYyhKK8BKr6dxoQKOPHwJnigUGvalTyH5QT20xhRjvDQSzVklK1elv3JbIhW3wiKEia3i2 X-Received: by 2002:a63:4041:0:b0:372:c918:631a with SMTP id n62-20020a634041000000b00372c918631amr5168422pga.370.1645163511703; Thu, 17 Feb 2022 21:51:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645163511; cv=none; d=google.com; s=arc-20160816; b=bJ8eeD8V1n3/ElSe+ZP/VsAzH/EL2Y9PN+PlbrBl6B5EDyWDmTK/a29j3YMLr42GMe oGLEii11s+ZxJYmIi73lFQrVtIRZ5BqO7EamKbE/zhtoFZhX2ZFeYfhSjCvj6TXfr2S7 SCnEdx4EbzNPBQhrtIPjPJtD/sQ53V7vLv9owTTWmcQV4u1Odv4jMCJPVcuOnoMV0DNI wmoF0xCYy22BT6kcHceMseeVmNpywTNQPQ+3ZS1MxV36S+6Lo07nDDTX71PsWu+kTjJA j3iuN0Mgub9Hcr3iGxpNfBUfhzyzD6+pVKk9SjwNOzMwDeJgWNwGs5roFqHWpPysLkO3 xAVw== 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=IeaS4+39e9ZB4zj8Ahd5mPRXYUi6qxaTU1lQ6cj92Kk=; b=Av/KwXRFFAzhp79zbgvqnnniO4gCIgdxoKfBFO6J0f57CThXrEASHjxpndidV2uwyw NsUV5aNLDxPlA39chb3GtrLkmLkUI9eYohI/zoxZDgdgLkB00iGOKg71s/tpI18bbwP0 e73XRmrniKuwJGwTPPj/NZwbvrjk2rb9Y2VDO2PsJhJHhCBNOvjUP4cYBorgwAR55KcH ktFhILkATIMjVM7b3cUOuMB10CQlJTbrni9yhOp0buiGXapcfQ4Vfkkb1rIltRCiWDnn wHMNYMgYVEHcyArFgPAj5y4UyyW5a/qp8mY7IsHEbR/Xl3JB2caxP0EvC/Hdi++jlq53 OP+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lvmvS5W0; 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 b5si1622634pfm.93.2022.02.17.21.51.34; Thu, 17 Feb 2022 21:51:51 -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=lvmvS5W0; 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 S230294AbiBRFfA (ORCPT + 99 others); Fri, 18 Feb 2022 00:35:00 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbiBRFe5 (ORCPT ); Fri, 18 Feb 2022 00:34:57 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07E601783AB for ; Thu, 17 Feb 2022 21:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645162481; x=1676698481; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=vZmmDTIxi0lu2DZF0PIAIbRLyfoDOnSLD948kCfctC0=; b=lvmvS5W0sTmCHltY3qEs6gKuWlaEa35MBzul1khdFmIFZ1WgWCpqUsKH lWHh4CzEBEEeLZ889zipoZ1Fry5f6Io/BPc5mMUnjpUdyg6hFImxiEdZ0 oXp82WbNSvSsrT/wtX+02mGQ0na8tiOPyFWSGQ0ffjgCYmlfhavQXzEOo Iq/cePYju049wnW1yJg8wZfvjMMghb49CIKZf6AXJh/w5ybl5Xkfv+lF7 vh5qRrG6Lo9UtBpNX2ZoHyYfgYMJg77DGQozEOQYgufHu+Ehu3f7tyHez 8Fenvj2obUekhnzolLH50NL/5YTyeqZ0lWVwZ5Wzd9lTuN+4YJ1Bx6rbI Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10261"; a="251255013" X-IronPort-AV: E=Sophos;i="5.88,377,1635231600"; d="scan'208";a="251255013" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 21:34:41 -0800 X-IronPort-AV: E=Sophos;i="5.88,377,1635231600"; d="scan'208";a="777898092" Received: from rbfawkes-mobl1.amr.corp.intel.com (HELO localhost) ([10.212.127.120]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 21:34:41 -0800 Date: Thu, 17 Feb 2022 21:34:41 -0800 From: Ira Weiny To: Dave Hansen Cc: Dave Hansen , "H. Peter Anvin" , Dan Williams , Fenghua Yu , Rick Edgecombe , linux-kernel@vger.kernel.org Subject: Re: [PATCH V8 19/44] mm/pkeys: PKS Testing, add pks_mk_*() tests Message-ID: References: <20220127175505.851391-1-ira.weiny@intel.com> <20220127175505.851391-20-ira.weiny@intel.com> <00b87c5f-b4ed-7593-827c-0e1114b8b456@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00b87c5f-b4ed-7593-827c-0e1114b8b456@intel.com> X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Tue, Feb 01, 2022 at 09:45:03AM -0800, Dave Hansen wrote: > On 1/27/22 09:54, ira.weiny@intel.com wrote: > > bool pks_test_callback(void) > > { > > - return false; > > + bool armed = (test_armed_key != 0); > > + > > + if (armed) { > > + pks_mk_readwrite(test_armed_key); > > + fault_cnt++; > > + } > > + > > + return armed; > > +} > > Where's the locking for all this? I don't think we need anything fancy, > but is there anything preventing the test from being started from > multiple threads at the same time? I think a simple global test mutex > would probably suffice. Good idea. Generally I don't see that happening but it is good to be safe. > > Also, pks_test_callback() needs at least a comment or two about what > it's doing. The previous patch which adds this call in the fault handler contains the following comment which is in the final code: /* * pks_test_callback() is called by the fault handler to indicate it saw a pkey * fault. * * NOTE: The callback is responsible for clearing any condition which would * cause the fault to re-trigger. */ Would you like more comments within the function? > > Does this work if you have a test armed and then you get an unrelated > PKS fault on another CPU? I think this will disarm the test from the > unrelated thread. This code will detect a false fault. But the other unrelated fault will work correctly. I've debated if the test code should use a specific fault callback... :-/ That breaks my test which iterates all keys... but would fix this problem. Ira