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 BBDACEB64D9 for ; Thu, 15 Jun 2023 12:46: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:In-Reply-To:MIME-Version: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=rIbb7cWUeUEmuIiD7+qXqWcRnUSQcwdeYoSMrdB8Khg=; b=dT4Az9wawItuhP DCSoNiFZtmJFwNPoDviIuTdlpFULbKaeZ30LPDkgnnL3Z4TV8Z7pnqJwbP6Wery/kS4uJxJ6u2fnV T059DqXQv6WVzIvID8k+OstF5Tpie+miuDLXSdkM6XKhSSZjnqQT85qlbrbXJPO3v5tCi6oANAxJz V+Uwju6nqosReVPrSqel+0OucPdcUVPI+NX+NrDBWVFdSjLm4KSEpp0FDj165VcVQlMH7KRuHZtpA lRMSarp1lIZYDRZxBsuykYBj3oKJaCoOM8+uOqqlS/wrabwE7md36eF4FZOwLaWCyvJeoBAUbL2Xy O3dbNcax/0iZciYxxjtw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9mMF-00Ev8t-0f; Thu, 15 Jun 2023 12:45:47 +0000 Received: from out-13.mta0.migadu.com ([2001:41d0:1004:224b::d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9mMC-00Ev7F-0C for linux-arm-kernel@lists.infradead.org; Thu, 15 Jun 2023 12:45:45 +0000 Date: Thu, 15 Jun 2023 12:45:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1686833139; 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=OsuKBXNSxqVmg16B7vlIhxgtAhh7lG9zEZU79hMDvk4=; b=Kke1Ymd3a/L03cy0cqbVKaxpdlGoxVGVuJgEjVDJMPEmGmQ3Y4GeqXPD3U213Fxx3cVBFD 13rYEX0JjG7UCV/b3kR6fA8pL2QBzQdjI6JAc1tMZoq90dZAUI2ZKZfxxC/SErPVSzRmbF In4aP9V9u3WsgmBksWQVEEsEnpIyz3M= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: kvmarm@lists.linux.dev, James Morse , Suzuki K Poulose , Zenghui Yu , Will Deacon , Catalin Marinas , Fuad Tabba , linux-arm-kernel@lists.infradead.org, surajjs@amazon.com, Cornelia Huck , Shameerali Kolothum Thodi , Jing Zhang Subject: Re: [PATCH v12 07/11] KVM: arm64: Use arm64_ftr_bits to sanitise ID register writes Message-ID: References: <20230609190054.1542113-1-oliver.upton@linux.dev> <20230609190054.1542113-8-oliver.upton@linux.dev> <878rckrjcl.wl-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <878rckrjcl.wl-maz@kernel.org> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230615_054544_264380_E9643F90 X-CRM114-Status: GOOD ( 19.70 ) 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 Hey Marc, On Thu, Jun 15, 2023 at 01:38:34PM +0100, Marc Zyngier wrote: > > @@ -1528,11 +1613,31 @@ static int get_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > static int set_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, > > u64 val) > > { > > - /* This is what we mean by invariant: you can't change it. */ > > - if (val != read_id_reg(vcpu, rd)) > > - return -EINVAL; > > + u32 id = reg_to_encoding(rd); > > + int ret; > > > > - return 0; > > + mutex_lock(&vcpu->kvm->arch.config_lock); > > + > > + /* > > + * Once the VM has started the ID registers are immutable. Reject any > > + * write that does not match the final register value. > > + */ > > + if (kvm_vm_has_ran_once(vcpu->kvm)) { > > + if (val != read_id_reg(vcpu, rd)) > > + ret = -EBUSY; > > + else > > + ret = 0; > > + > > + mutex_unlock(&vcpu->kvm->arch.config_lock); > > + return ret; > > + } > > + > > + ret = arm64_check_features(vcpu, rd, val); > > + if (!ret) > > + IDREG(vcpu->kvm, id) = val; > > + > > + mutex_unlock(&vcpu->kvm->arch.config_lock); > > + return ret; > > ... we now end-up with a *new* error code that userspace was never > able to see so far. > > This may not be a big deal, but I'd rather err on the side of caution > by keeping the current, slightly less precise error code. I completely agree, thanks for catching this. There's already enough deliberate (theorectical) breakage brought about by this series, want to avoid any unintended fallout :) I plan on taking this, and I'll apply a fix on top to dumb down the return. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel