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 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A157C433E2 for ; Sat, 5 Sep 2020 13:16:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAB3320760 for ; Sat, 5 Sep 2020 13:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599311771; bh=yrAZ7cGBODumQCEPLK1ol44lgWUhFr7nPfBOeegGfWY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=fSM6BfYfVIfAsA7/GgfHtY/I0/msC0YCzVot5Q7XhbZkvQloel0rjKSbhIyUyA7eP cRmDiTAg4FC5UJ7/O0tNRL1Nmo9SezFf2T/5JSUz0JilFVzTI1A1yV+9jeviu1dPjh jUc7V/ftiUrxDSGbeaSANvSCAnHfuxSrgSp/2gz8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728314AbgIENQL (ORCPT ); Sat, 5 Sep 2020 09:16:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:52438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726261AbgIENQK (ORCPT ); Sat, 5 Sep 2020 09:16:10 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 55E072072D; Sat, 5 Sep 2020 13:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599311769; bh=yrAZ7cGBODumQCEPLK1ol44lgWUhFr7nPfBOeegGfWY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=0Zjt1tOpVaP0QaDqkJws6HevuqmpCKzvVOUQsKSI0jT2Hrgsq/S8kncaILsIF/RL3 H5Mq0bNgQsxfXCe9y+O99Tvywv4viqhZA4cHCFlFcHUJAeCaNDaX+QmTVBKzSuMZ4x EZF5MLu7ZhUUkXea7/nTXXJfk0qjvTlLRVxAZ6iQ= Received: from [185.104.136.29] (helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kEY35-009N2d-Kr; Sat, 05 Sep 2020 14:16:07 +0100 Date: Sat, 05 Sep 2020 14:16:06 +0100 Message-ID: <874kocmkix.wl-maz@kernel.org> From: Marc Zyngier To: Jonathan Cameron Cc: , , , Lorenzo Pieralisi , Suzuki K Poulose , Christoffer Dall , James Morse , , Julien Thierry Subject: Re: [PATCH 22/23] KVM: arm64: Add a rVIC/rVID in-kernel implementation In-Reply-To: <20200904170036.00003bda@Huawei.com> References: <20200903152610.1078827-1-maz@kernel.org> <20200903152610.1078827-23-maz@kernel.org> <20200904170036.00003bda@Huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 EasyPG/1.0.0 Emacs/26.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.104.136.29 X-SA-Exim-Rcpt-To: Jonathan.Cameron@Huawei.com, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, lorenzo.pieralisi@arm.com, suzuki.poulose@arm.com, Christoffer.Dall@arm.com, james.morse@arm.com, kernel-team@android.com, julien.thierry.kdev@gmail.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, 04 Sep 2020 17:00:36 +0100, Jonathan Cameron wrote: > > On Thu, 3 Sep 2020 16:26:09 +0100 > Marc Zyngier wrote: [...] > > +static int rvic_set_attr(struct kvm_device *dev, struct kvm_device_attr *attr) > > +{ > > + struct rvic_vm_data *data; > > + struct kvm_vcpu *vcpu; > > + u32 __user *uaddr, val; > > + u16 trusted, total; > > + int i, ret = -ENXIO; > > + > > + mutex_lock(&dev->kvm->lock); > > + > > + switch (attr->group) { > > + case KVM_DEV_ARM_RVIC_GRP_NR_IRQS: > > + if (attr->attr) > > + break; > > + > > + if (dev->kvm->arch.irqchip_data) { > > + ret = -EBUSY; > > + break; > > + } > > + > > + uaddr = (u32 __user *)(uintptr_t)attr->addr; > > + if (get_user(val, uaddr)) { > > + ret = -EFAULT; > > + break; > > + } > > + > > + trusted = FIELD_GET(KVM_DEV_ARM_RVIC_GRP_NR_TRUSTED_MASK, val); > > + total = FIELD_GET(KVM_DEV_ARM_RVIC_GRP_NR_TOTAL_MASK, val); > > + if (total < trusted || trusted < 32 || total < 64 || > > + trusted % 32 || total % 32 || total > 2048) { > > As I read the spec, we need at least 32 untrusted. (R0058) > This condition seems to allow that if trusted = 64 and untrusted = 0 Well spotted. I think the following would capture the constraints correctly: if (total <= trusted || trusted < 32 || total < 64 || trusted % 32 || total % 32 || total > 2048) { On the other hand, I wonder if this code would gain from being directly written in terms of trusted/untrusted, rather than trusted/total. It could make the reading against the spec easier. Thanks, M. -- Without deviation from the norm, progress is not possible.