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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F620C28D13 for ; Sat, 20 Aug 2022 00:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bOyQtCPVcBM1SgFzc+Fq5vUlDETC2qBlL09Xw0JRQmE=; b=DIsxujlCJxd+pX F2vEGCETKQ6wy2f4Z0cZgHBuepM6O5o7QYqg62qPwduJ1qsDB963cNIRAV7gPefWIEe4CWwzGiKeI EfFNIgZmiyDyR0ofSom6sTMP0KGgae823BOqXqQtSYUYI9JB+7z6PXEA2SZeDg1FsdN6vqkQcrs15 wLH5ZHFe7ZgKq3M1o4M+KplkXZIAsF+dZWHV3HwFrzIj1ijs0CU9PnKmqY99jrUtINI0BrGO8FDw3 CDM+6Inv/1WbUTHH7ajN0t9imj+olDqkikmqTo/svLa7QkXfRcTyIYqOiyYmqXLl5DvUjmWixeeMT bjOQbUfx7eODkEWAH5Pw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPCEO-00Dqj0-0I; Sat, 20 Aug 2022 00:20:52 +0000 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oPCEK-00Dqed-4B for linux-arm-kernel@lists.infradead.org; Sat, 20 Aug 2022 00:20:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660954848; x=1692490848; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=ppiNH3/8zOgRRZ4VODvQXyt9/aa99fZxQF+1AoKV3C4=; b=g8ZvmGf2B+c6fAx7Y7M55+lkc1d+1jf8hWDKPdokqTbzytjqYwKedHkD bC0zBDjj8UbFOiikG32b454v4+NHbx/wu8M19r2MQFD0amY6Z7q4YHyln 9vS7m3W7211oUp040Mu69J/LwYI7iKI39iNGkJYrJ+xffXA0A20abcfyF mk52bLXuLP1WnES9HhnnxjxSvChWlbL/kUzZVugr4Zbr8aVv2LxyFNjU9 VoFL+GjYH0lC0asGrRRWFyuQuPGW3ZsFAM4a9i33sRLxiXIGS2hfb5l0u QGUdsrCZViCg324IMQn3gqw6vP2lg1sp7w5aWkH0hjRl3qeTBp7Iz62my g==; X-IronPort-AV: E=McAfee;i="6500,9779,10444"; a="354858950" X-IronPort-AV: E=Sophos;i="5.93,249,1654585200"; d="scan'208";a="354858950" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2022 17:20:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,249,1654585200"; d="scan'208";a="641430077" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga001.jf.intel.com with ESMTP; 19 Aug 2022 17:20:45 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 19 Aug 2022 17:20:44 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 19 Aug 2022 17:20:44 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Fri, 19 Aug 2022 17:20:44 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.172) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.28; Fri, 19 Aug 2022 17:20:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iF/NUiW5Zb1Dcemf32LDFfMQA0RlvcbRx/iflhZen8ie8MkD8l1LIROh00vK7yl4Agzt5mQv+rQm6RMdnsBm2IxxvRlF30IxQw1BOnR1Mlz5YM1ACdoBlVgbAuOwFl/WuPqwxFCaXpfSqeJ3D+s+OicHFjuOXuP4FAZal9byrurlNRRscVzIwmrSyq4Fs0qZLiyZAnua1CNHbLHw5Tm5a99rp4gnn0LY21SADBEQoU3SgzFqkDZTAaOuDh9X3/BqdHCEjCSJJyMvh9Lx6BPvd4iKsCLklCggOALbaOb9jKv6bsOc+5W5IB/nRwFZkzXXJjBXw5saiMRY+fnZ1Fzqog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dj9ayF6dFNAH75gZUg8M4OzxDWAcvRfKdnCPKagkT9k=; b=FQ6VIfRK6GL3O2TaE7rks71q4q4knSi8VRjbCcFjoSX2cnASpsi5f8gxettm0mWPjh7ApE8PBezIo9PHQRzMRGLMhJMGwUp8Q8H1+9D7EiQ3ZmqDwfvWTrNJiYUsUfNEBCL2LmWhoQ+qRen3xzoHvWbBX+dpWchlJdDQbN3R59m3NYjLjiYSnlRaODCg16eO6fONxJT1decQH7Zsf4zAkYqP7PZCs9UFdYNw17Y9UwqxiUWfL7TzWZtNX4jEpbTsPpioNzpNSwocnm/VxGDH+odkUCiss9NoYy4okvATOmFPWVtilUfiAOXJEQiOi1sT1fESVzklF9HMll2lVg0LdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SA1PR11MB6733.namprd11.prod.outlook.com (2603:10b6:806:25c::17) by BN8PR11MB3571.namprd11.prod.outlook.com (2603:10b6:408:8f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Sat, 20 Aug 2022 00:20:41 +0000 Received: from SA1PR11MB6733.namprd11.prod.outlook.com ([fe80::4ef:8e90:8ed9:870]) by SA1PR11MB6733.namprd11.prod.outlook.com ([fe80::4ef:8e90:8ed9:870%5]) with mapi id 15.20.5525.011; Sat, 20 Aug 2022 00:20:41 +0000 Date: Fri, 19 Aug 2022 17:20:36 -0700 From: Ira Weiny To: Davidlohr Bueso CC: , , , , , , , , , , , , , Subject: Re: [PATCH v2] arch/cacheflush: Introduce flush_all_caches() Message-ID: References: <20220819171024.1766857-1-dave@stgolabs.net> Content-Disposition: inline In-Reply-To: <20220819171024.1766857-1-dave@stgolabs.net> X-ClientProxiedBy: BY3PR04CA0012.namprd04.prod.outlook.com (2603:10b6:a03:217::17) To SA1PR11MB6733.namprd11.prod.outlook.com (2603:10b6:806:25c::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d1a30ed-6e64-4e91-0279-08da8241d0a6 X-MS-TrafficTypeDiagnostic: BN8PR11MB3571:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pf7LOt/rgBg2pf7VhiPSWo7hX59vP34PdZ4dFetr7KYvNMvtGPMAJ9U+Yfiq3NlQIJrKda3DYCl//QrZDAOtcM2aEISNd8/dr45yMBGFsQcuVHRL0FXhfDQK3rqaIEv+WQkQ8+1Mny2q26GRxls+l5w7DWHmo4ZQGltW1801o6zKYpMts06vum71u3BQgctICYCmzVb8YI0R1PYCwz7kWuzx4OjU7wAz+7RD4xVoyRU66HOCFB7iUNPfO+4pjB0kVSWLnY9fAvIWFfJj3zkoWWRb8VjLq9HqGJNYJ2M4RGe9RXTopEc6pKHgDRib5QAj86dNvUWS1FcoVbal7dur4gt+LG8h/sAmTQZC/rQcCmfGVXfsTaYOVaAv2ll7ytesHC1tkn/RfJoawR42EwMPNsnLk7ECzZwgB1emnJEDItMk+pwEQ2UbpZT0sjPY3E8kW6CYkFn81BApPZmpjxL07iMJIV75WdyDsqF/k4/hF4FPGfoxzIZzimkW/nOQS4jsNTV553xXlnXf1Az4px7pPedvmR6WL31KJbXAoH8Bcs3iB5bBVocNIWiw3wMpLw4sp82CUzUoPAjmGEJ7nFs3yseUdvmvYPMnAvoD3/01cUM4PsrO3mcLrKfjO8rug6lwY7DyneWEmYijIpp6sZKv0x5qpBqbg3n08COc6aTpGyjQ5FuncYy6EH4Bvmzy4cIfIqlFh7Zo9Zjo+dWMcJHqRnuxN17ItNPeMyQe6xMuPIlb3EicSA6PAJSyLtRj3j1h X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR11MB6733.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(7916004)(136003)(366004)(346002)(396003)(39860400002)(376002)(7416002)(6916009)(38100700002)(86362001)(83380400001)(186003)(8676002)(6486002)(66476007)(66946007)(66556008)(4326008)(316002)(82960400001)(8936002)(5660300002)(44832011)(9686003)(6506007)(2906002)(26005)(478600001)(41300700001)(6666004)(33716001)(6512007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?30d0/F33/EI060Ajh8CVZ54ngsmKjzoLd94XOufO2+OTsbTzIOe+lHGDM09j?= =?us-ascii?Q?0d0TDy/94jIHnWEgwa1iSCqwZzT2ODHpDETcYuH0L/qy1x0Wn/BzOvFDJJD8?= =?us-ascii?Q?5K+LZdXgjX/j96UEW1rSyM0QhD1pI5cNMzreu44tf9NjzQ+hf4BHhj8SZM2v?= =?us-ascii?Q?EEzTVLAQkZkM9x/iN+tMBbv08e+vBEKskTJRtzss35yx2Fj9PKicpNZ/uot2?= =?us-ascii?Q?1bYAChidhkp25uDbNzMh2vabG+zYhiynYzNV4oXxzpYhMKGnXLw+tIdwRYLd?= =?us-ascii?Q?paT8EHPKzNMJyn0ZuQBxrI5yjSFPad+viHlyCvied23tgH6DtO35tblpmFYQ?= =?us-ascii?Q?n7ZIhIGuAb8mgmEL1RvcQqNMPMbjsmiOHsVUdI0P88k0OqzTP5Tm++/Pzyph?= =?us-ascii?Q?Bs6asYOfFZhBaDCBzJ3J/gFrGX4bCcL4uQGeHV+d7mWhUcduUe7kEJqAf7aw?= =?us-ascii?Q?wiBZsfJ7QdXyr+t8ZFVmjnIAY8oZ+KElg3LcGmnZ6Y9OQs8guxAEUJ3kGXy5?= =?us-ascii?Q?DoXsjrjK29mtTp+yo2dllCOjG9G6wknB7SHiPnXXqo79FuhnjoTr7rToP1l9?= =?us-ascii?Q?xu9FZe3tHrskigAwPBRjgByhG2VczR4MgrXmYHzgpRP/pri1tlES2pylAzTS?= =?us-ascii?Q?iLlq9SeWsLCkiuPXHezTWlN4qe7zS3q8Wll6I2GBEhzvyIxIV27/HcN18nuL?= =?us-ascii?Q?ReNlctoRD+1qhwUfuaSmFbxqAfNZ5k55JBQCC+SJE35LXMxLEpdt+8dbE1qa?= =?us-ascii?Q?oV6RN/5yvR8PlVQz1xiDv+cGlrXAtZzPzoHoaT48F/DPqCYHaaraZj5d66YE?= =?us-ascii?Q?eKT4puCwMamABLNL8lTmA1oDB+LZ2bAdjBrg5Q9U9yRTSdfNq/VHDbiymjzG?= =?us-ascii?Q?ZsEl2qmBFVp6IwkhvKGQ35bXfLbpIUVAJDyaZzzQUZUunFCWN4e6cyKz9y1r?= =?us-ascii?Q?GPxO+QmS2bs8Yn1UFKx/DWfMrDBJJWwo0NCRl+ZaYEcJ9xtnmbQHQGqkLnMj?= =?us-ascii?Q?ubBz/RuE9Jm26RUHJRGBSgM5R2ovWC6mC95Wc74X2ABXNpiYgVq7NjXEp1Tn?= =?us-ascii?Q?lA9cDS249TOMHoLkIM5TTmlkpP5rmMeFf+qCyZon8JbatFANssLQWVun/qm6?= =?us-ascii?Q?2b7L2B4yAPZpSdfBZEDE4fbfUUcVwR0tDZ0uB/0Zb2c7g2gBHGcNVKvi+TWu?= =?us-ascii?Q?SIz0gvdEF8dh8JOsGQ0u2IHv6rMgnbrgc0WLjQVdsqxc/hpN3GJcpuFblSWp?= =?us-ascii?Q?xUeRXixvBtItTxdp+HKNQao/QdrT8Db5HUZ8ZcJOglVjbxtT97fiWIXBw+62?= =?us-ascii?Q?IaAB03P5r7bOIhfoZFRnleQoiuSU1rga1nUxt+WFz5hu82SYQnCQRa9Xfsyu?= =?us-ascii?Q?Os1GEL5Qo0A77QwddLxs5PyppxXE+v50Hf9+1IWvg7Vc+X3StdfoOklkmhaH?= =?us-ascii?Q?UfqGhiI0gnNsVL6qff6C0HmYWSfPjYGmfWABhmYlNLcWkh1unVd5Xp6l2vYB?= =?us-ascii?Q?3dL5NrUIVnxWLGBH1X4XVYayHjkUIg6n87/HM5hoXfLR9n++m9n5QYDYDO6F?= =?us-ascii?Q?Ceqan+S3zvdXr2RHu7aud18aFjeU0DuNIq0sx0wJ?= X-MS-Exchange-CrossTenant-Network-Message-Id: 3d1a30ed-6e64-4e91-0279-08da8241d0a6 X-MS-Exchange-CrossTenant-AuthSource: SA1PR11MB6733.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2022 00:20:41.2309 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: H1qgSnbd/jSfOIBSnTmNM446d6rHUjkMX/3/GqYYAyvvqyzaU5qREV8X6ftj1FcpkwRVJsd8Qn4B4VOV6caXVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR11MB3571 X-OriginatorOrg: intel.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220819_172048_281056_EBDA6446 X-CRM114-Status: GOOD ( 31.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Aug 19, 2022 at 10:10:24AM -0700, Davidlohr Bueso wrote: > With CXL security features, global CPU cache flushing nvdimm requirements > are no longer specific to that subsystem, even beyond the scope of > security_ops. CXL will need such semantics for features not necessarily > limited to persistent memory. > > The functionality this is enabling is to be able to instantaneously > secure erase potentially terabytes of memory at once and the kernel > needs to be sure that none of the data from before the secure is still > present in the cache. It is also used when unlocking a memory device > where speculative reads and firmware accesses could have cached poison > from before the device was unlocked. > > This capability is typically only used once per-boot (for unlock), or > once per bare metal provisioning event (secure erase), like when handing > off the system to another tenant or decomissioning a device. That small > scope plus the fact that none of this is available to a VM limits the > potential damage. > > While the scope of this is for physical address space, add a new > flush_all_caches() in cacheflush headers such that each architecture > can define it, when capable. For x86 just use the wbinvd hammer and > prevent any other arch from being capable. > > Signed-off-by: Davidlohr Bueso > --- > > Changes from v1 (https://lore.kernel.org/all/20220815160706.tqd42dv24tgb7x7y@offworld/): > - Added comments and improved changelog to reflect this is > routine should be avoided and not considered a general API (Peter, Dan). > > arch/x86/include/asm/cacheflush.h | 4 +++ > drivers/acpi/nfit/intel.c | 41 ++++++++++++++----------------- > include/asm-generic/cacheflush.h | 31 +++++++++++++++++++++++ > 3 files changed, 53 insertions(+), 23 deletions(-) > > diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h > index b192d917a6d0..ac4d4fd4e508 100644 > --- a/arch/x86/include/asm/cacheflush.h > +++ b/arch/x86/include/asm/cacheflush.h > @@ -10,4 +10,8 @@ > > void clflush_cache_range(void *addr, unsigned int size); > > +/* see comments in the stub version */ > +#define flush_all_caches() \ > + do { wbinvd_on_all_cpus(); } while(0) > + > #endif /* _ASM_X86_CACHEFLUSH_H */ > diff --git a/drivers/acpi/nfit/intel.c b/drivers/acpi/nfit/intel.c > index 8dd792a55730..f2f6c31e6ab7 100644 > --- a/drivers/acpi/nfit/intel.c > +++ b/drivers/acpi/nfit/intel.c > @@ -4,6 +4,7 @@ > #include > #include > #include > +#include > #include "intel.h" > #include "nfit.h" > > @@ -190,8 +191,6 @@ static int intel_security_change_key(struct nvdimm *nvdimm, > } > } > > -static void nvdimm_invalidate_cache(void); > - > static int __maybe_unused intel_security_unlock(struct nvdimm *nvdimm, > const struct nvdimm_key_data *key_data) > { > @@ -210,6 +209,9 @@ static int __maybe_unused intel_security_unlock(struct nvdimm *nvdimm, > }; > int rc; > > + if (!flush_all_caches_capable()) > + return -EINVAL; > + > if (!test_bit(NVDIMM_INTEL_UNLOCK_UNIT, &nfit_mem->dsm_mask)) > return -ENOTTY; > > @@ -228,7 +230,7 @@ static int __maybe_unused intel_security_unlock(struct nvdimm *nvdimm, > } > > /* DIMM unlocked, invalidate all CPU caches before we read it */ > - nvdimm_invalidate_cache(); > + flush_all_caches(); > > return 0; > } > @@ -294,11 +296,14 @@ static int __maybe_unused intel_security_erase(struct nvdimm *nvdimm, > }, > }; > > + if (!flush_all_caches_capable()) > + return -EINVAL; > + > if (!test_bit(cmd, &nfit_mem->dsm_mask)) > return -ENOTTY; > > /* flush all cache before we erase DIMM */ > - nvdimm_invalidate_cache(); > + flush_all_caches(); > memcpy(nd_cmd.cmd.passphrase, key->data, > sizeof(nd_cmd.cmd.passphrase)); > rc = nvdimm_ctl(nvdimm, ND_CMD_CALL, &nd_cmd, sizeof(nd_cmd), NULL); > @@ -318,7 +323,7 @@ static int __maybe_unused intel_security_erase(struct nvdimm *nvdimm, > } > > /* DIMM erased, invalidate all CPU caches before we read it */ > - nvdimm_invalidate_cache(); > + flush_all_caches(); > return 0; > } > > @@ -338,6 +343,9 @@ static int __maybe_unused intel_security_query_overwrite(struct nvdimm *nvdimm) > }, > }; > > + if (!flush_all_caches_capable()) > + return -EINVAL; > + > if (!test_bit(NVDIMM_INTEL_QUERY_OVERWRITE, &nfit_mem->dsm_mask)) > return -ENOTTY; > > @@ -355,7 +363,7 @@ static int __maybe_unused intel_security_query_overwrite(struct nvdimm *nvdimm) > } > > /* flush all cache before we make the nvdimms available */ > - nvdimm_invalidate_cache(); > + flush_all_caches(); > return 0; > } > > @@ -377,11 +385,14 @@ static int __maybe_unused intel_security_overwrite(struct nvdimm *nvdimm, > }, > }; > > + if (!flush_all_caches_capable()) > + return -EINVAL; > + > if (!test_bit(NVDIMM_INTEL_OVERWRITE, &nfit_mem->dsm_mask)) > return -ENOTTY; > > /* flush all cache before we erase DIMM */ > - nvdimm_invalidate_cache(); > + flush_all_caches(); > memcpy(nd_cmd.cmd.passphrase, nkey->data, > sizeof(nd_cmd.cmd.passphrase)); > rc = nvdimm_ctl(nvdimm, ND_CMD_CALL, &nd_cmd, sizeof(nd_cmd), NULL); > @@ -401,22 +412,6 @@ static int __maybe_unused intel_security_overwrite(struct nvdimm *nvdimm, > } > } > > -/* > - * TODO: define a cross arch wbinvd equivalent when/if > - * NVDIMM_FAMILY_INTEL command support arrives on another arch. > - */ > -#ifdef CONFIG_X86 > -static void nvdimm_invalidate_cache(void) > -{ > - wbinvd_on_all_cpus(); > -} > -#else > -static void nvdimm_invalidate_cache(void) > -{ > - WARN_ON_ONCE("cache invalidation required after unlock\n"); > -} > -#endif > - > static const struct nvdimm_security_ops __intel_security_ops = { > .get_flags = intel_security_flags, > .freeze = intel_security_freeze, > diff --git a/include/asm-generic/cacheflush.h b/include/asm-generic/cacheflush.h > index 4f07afacbc23..89f310f92498 100644 > --- a/include/asm-generic/cacheflush.h > +++ b/include/asm-generic/cacheflush.h > @@ -115,4 +115,35 @@ static inline void flush_cache_vunmap(unsigned long start, unsigned long end) > memcpy(dst, src, len) > #endif > > +/* > + * Flush the entire caches across all CPUs, however: > + * > + * YOU DO NOT WANT TO USE THIS FUNCTION. > + * > + * It is considered a big hammer and can affect overall > + * system performance and increase latency/response times. > + * As such it is not for general usage, but for specific use > + * cases involving instantaneously invalidating wide swaths > + * of memory on bare metal. > + > + * Unlike the APIs above, this function can be defined on > + * architectures which have VIPT or PIPT caches, and thus is > + * beyond the scope of virtual to physical mappings/page > + * tables changing. > + * > + * The limitation here is that the architectures that make > + * use of it must can actually comply with the semantics, "must can"? Did you mean "must"? > + * such as those which caches are in a consistent state. The > + * caller can verify the situation early on. > + */ > +#ifndef flush_all_caches > +# define flush_all_caches_capable() false > +static inline void flush_all_caches(void) > +{ > + WARN_ON_ONCE("cache invalidation required\n"); > +} With the addition of flush_all_caches_capable() will flush_all_caches() ever be called? Ira > +#else > +# define flush_all_caches_capable() true > +#endif > + > #endif /* _ASM_GENERIC_CACHEFLUSH_H */ > -- > 2.37.2 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel