Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2497439rwb; Thu, 17 Nov 2022 11:35:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf7kPGZ0yCO191nYGULBuv6JELxWBYyshBI09bHq17MYaMt3exTkNqvLalQUVMyOMh4JY4Jv X-Received: by 2002:a17:906:8d86:b0:78d:4742:bb62 with SMTP id ry6-20020a1709068d8600b0078d4742bb62mr3398534ejc.43.1668713727710; Thu, 17 Nov 2022 11:35:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668713727; cv=none; d=google.com; s=arc-20160816; b=AmlFRJN8OIvmlFJwWQdA4PZxoD1g5v7czV9eXZoQq2/IkHWZy4KCf/Di96BTqEM89R Q3OqsKBhbiSHxDCc23sObuXWGyAWumEFhoyJV0mFH/NVrgBeysuFHGu+6/xYuZpQHT7M AsZChJmcuoWXHP+oPZ6HOQ0NSUIxdIEophMqCooIjHxP/QpVzBAd5HjOFaQauuRZKJvg U+I6N8RIN299uoU5yIE5Bk6Eg0p3/n+7Yn/t5xpu6tnogrMRJ3eTNfsY9drDiFkMtn1m Zs9p3KX2MFxkmZGs290QhaKESxINUbQAAgXz8YXg3c3IYVc/k/nalxk4JtTr9YUG3Aox cHfg== 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:dkim-signature:date; bh=IwFVbORM3lkiyGr/+WKBEIKDDUjLVlji+1Do7NRWw78=; b=IUBdegelNm0rIPOHITVMx3HllHFiojUsYpZEBSfL7bwaYg8TGZ3L0NRY7qkeGU/4WA aTckqteS8DygCSFvw1P874O5jvNpqQtFltVc5GIKNzpH+RT3hcRdeF5fZWupuJ7VbRKq 4sCpe6qCa/wWYj+AoKCNARgo9HPafH+e3Q4vSb+QoM2R1EMXT+RarpIZwrhNgjAObCuT GqVGBRfmQ0ZTUnnRVkINFI5lgyPptdm8UoDQB7PGYPxw8pfVA+m0T9mDadAVHxikqxW7 VJzOUHiguNnAoceGj1O3G7gf70EK1GxlqcZWBeys5HNOsZ9r4Th7Vd2A8auqyMiO7gj9 ZNWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=EPyAipG0; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id co20-20020a0564020c1400b004589ea2d983si1442173edb.287.2022.11.17.11.35.03; Thu, 17 Nov 2022 11:35:27 -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=@linux.dev header.s=key1 header.b=EPyAipG0; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240510AbiKQSXe (ORCPT + 92 others); Thu, 17 Nov 2022 13:23:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240223AbiKQSXb (ORCPT ); Thu, 17 Nov 2022 13:23:31 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54FDCCCD; Thu, 17 Nov 2022 10:23:29 -0800 (PST) Date: Thu, 17 Nov 2022 18:23:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1668709407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IwFVbORM3lkiyGr/+WKBEIKDDUjLVlji+1Do7NRWw78=; b=EPyAipG0Y0uPsli1k4NCyXaG1sfwgMAXa1UEGeItlrHceWFfKnGKSK3iyCq3wzRd3DAXf7 fI3727AVsagQ3/4GUDaNBDmMWcj1o723mEYNDHciLRGE/FuJmJkXW/hDR44vfmraH8cu2c n24UNBnI5YYa/xXMwJpR42PArIHvi2Q= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Will Deacon Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, Marek Szyprowski , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] KVM: arm64: Don't acquire RCU read lock for exclusive table walks Message-ID: References: <20221116165655.2649475-1-oliver.upton@linux.dev> <20221116165655.2649475-3-oliver.upton@linux.dev> <20221117174951.GA2916@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221117174951.GA2916@willie-the-truck> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS 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 Hi Will, Thanks for having a look. On Thu, Nov 17, 2022 at 05:49:52PM +0000, Will Deacon wrote: > On Wed, Nov 16, 2022 at 04:56:55PM +0000, Oliver Upton wrote: [...] > > -static inline void kvm_pgtable_walk_begin(void) {} > > -static inline void kvm_pgtable_walk_end(void) {} > > +static inline void kvm_pgtable_walk_begin(struct kvm_pgtable_walker *walker) > > +{ > > + /* > > + * Due to the lack of RCU (or a similar protection scheme), only > > + * non-shared table walkers are allowed in the hypervisor. > > + */ > > + WARN_ON(walker->flags & KVM_PGTABLE_WALK_SHARED); > > +} > > I think it would be better to propagate the error to the caller rather > than WARN here. I'd really like to warn somewhere though since we're rather fscked at this point. Keeping that WARN close to the exceptional condition would help w/ debugging. Were you envisioning bubbling the error all the way back up (i.e. early return from kvm_pgtable_walk())? I had really only intended these to indirect lock acquisition/release, so the error handling on the caller side feels weird: static inline int kvm_pgtable_walk_begin(struct kvm_pgtable_walker *walker) { if (WARN_ON(walker->flags & KVM_PGTABLE_WALK_SHARED)) return -EPERM; return 0; } r = kvm_pgtable_walk_begin() if (r) return r; r = _kvm_pgtable_walk(); kvm_pgtable_walk_end(); > Since you're rejigging things anyway, can you have this > function return int? If having this is a strong motivator I can do a v4. -- Thanks, Oliver