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=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 9E780C433E0 for ; Tue, 26 May 2020 16:29:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E73320787 for ; Tue, 26 May 2020 16:29:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729769AbgEZQ3p (ORCPT ); Tue, 26 May 2020 12:29:45 -0400 Received: from foss.arm.com ([217.140.110.172]:53280 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729594AbgEZQ3p (ORCPT ); Tue, 26 May 2020 12:29:45 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C352B30E; Tue, 26 May 2020 09:29:44 -0700 (PDT) Received: from [192.168.0.14] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C53183F52E; Tue, 26 May 2020 09:29:42 -0700 (PDT) From: James Morse Subject: Re: [PATCH 19/26] KVM: arm64: Make struct kvm_regs userspace-only To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Andre Przywara , Christoffer Dall , Dave Martin , Jintack Lim , Alexandru Elisei , George Cherian , "Zengtao (B)" , Will Deacon , Catalin Marinas , Mark Rutland , Julien Thierry , Suzuki K Poulose References: <20200422120050.3693593-1-maz@kernel.org> <20200422120050.3693593-20-maz@kernel.org> Message-ID: <0a38305f-77f8-11b0-cb74-2bec07ce0a0a@arm.com> Date: Tue, 26 May 2020 17:29:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200422120050.3693593-20-maz@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Marc, On 22/04/2020 13:00, Marc Zyngier wrote: > struct kvm_regs is used by userspace to indicate which register gets > accessed by the {GET,SET}_ONE_REG API. But as we're about to refactor > the layout of the in-kernel register structures, we need the kernel to > move away from it. > > Let's make kvm_regs userspace only, and let the kernel map it to its own > internal representation. > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > index 23ebe51410f06..9fec9231b63e2 100644 > --- a/arch/arm64/kvm/guest.c > +++ b/arch/arm64/kvm/guest.c > @@ -102,6 +102,55 @@ static int core_reg_size_from_offset(const struct kvm_vcpu *vcpu, u64 off) > return size; > } > > +static void *core_reg_addr(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > +{ > + u64 off = core_reg_offset_from_id(reg->id); > + > + switch (off) { > + default: > + return NULL; Doesn't this switch statement catch an out of range offset, and a misaligned offset? ... We still test for those explicitly in the caller. Better safe than implicit? > + } > +} With the reset thing reported by Zenghui and Zengtao on the previous patch fixed: Reviewed-by: James Morse (otherwise struct kvm_regs isn't userspace-only!) Thanks, James 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=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 ADAA6C433DF for ; Tue, 26 May 2020 16:29:48 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 654D920776 for ; Tue, 26 May 2020 16:29:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 654D920776 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 1ECB14B173; Tue, 26 May 2020 12:29:48 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kbO6RKvc229Y; Tue, 26 May 2020 12:29:47 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 0A5E44B15C; Tue, 26 May 2020 12:29:47 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 18CFB4B15C for ; Tue, 26 May 2020 12:29:46 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NvG0Uy5XOjnL for ; Tue, 26 May 2020 12:29:45 -0400 (EDT) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 168B74B0F4 for ; Tue, 26 May 2020 12:29:45 -0400 (EDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C352B30E; Tue, 26 May 2020 09:29:44 -0700 (PDT) Received: from [192.168.0.14] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C53183F52E; Tue, 26 May 2020 09:29:42 -0700 (PDT) From: James Morse Subject: Re: [PATCH 19/26] KVM: arm64: Make struct kvm_regs userspace-only To: Marc Zyngier References: <20200422120050.3693593-1-maz@kernel.org> <20200422120050.3693593-20-maz@kernel.org> Message-ID: <0a38305f-77f8-11b0-cb74-2bec07ce0a0a@arm.com> Date: Tue, 26 May 2020 17:29:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200422120050.3693593-20-maz@kernel.org> Content-Language: en-GB Cc: kvm@vger.kernel.org, Andre Przywara , kvmarm@lists.cs.columbia.edu, Will Deacon , George Cherian , "Zengtao \(B\)" , Catalin Marinas , Dave Martin , linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Hi Marc, On 22/04/2020 13:00, Marc Zyngier wrote: > struct kvm_regs is used by userspace to indicate which register gets > accessed by the {GET,SET}_ONE_REG API. But as we're about to refactor > the layout of the in-kernel register structures, we need the kernel to > move away from it. > > Let's make kvm_regs userspace only, and let the kernel map it to its own > internal representation. > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > index 23ebe51410f06..9fec9231b63e2 100644 > --- a/arch/arm64/kvm/guest.c > +++ b/arch/arm64/kvm/guest.c > @@ -102,6 +102,55 @@ static int core_reg_size_from_offset(const struct kvm_vcpu *vcpu, u64 off) > return size; > } > > +static void *core_reg_addr(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > +{ > + u64 off = core_reg_offset_from_id(reg->id); > + > + switch (off) { > + default: > + return NULL; Doesn't this switch statement catch an out of range offset, and a misaligned offset? ... We still test for those explicitly in the caller. Better safe than implicit? > + } > +} With the reset thing reported by Zenghui and Zengtao on the previous patch fixed: Reviewed-by: James Morse (otherwise struct kvm_regs isn't userspace-only!) Thanks, James _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 56A56C433E0 for ; Tue, 26 May 2020 16:29:56 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 26B2F20849 for ; Tue, 26 May 2020 16:29:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cqpV/1Ik" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 26B2F20849 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:References:To:Subject:From:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AQR6x2T3PGEh5Ge7lHkZHNxkHZDwJ3rvOXqOdgDp7eU=; b=cqpV/1IkjD4+ti 1bTDIYlYUGz1V5IdqcV6I0SCFU4B/s3SiTGtTL/a/t6Xxg6c674vB5UIwsaj0Iyi4eIQZhQ7rVvSC FpTxbo+z8gQLC7R1729tkZWj460zRz/JC6N91fxHHEXNdnS9Dyh4vff5hgnfEnJR0m6DTNbU6OOFX 68QnJmrbf+i0q5Viewz5RoRv7OxdP7erO4uS/kO4dnOG0b+kyoiHZf+n9gGao73wy9DJqa5JhMNWI w2ig2FZ5ww3jT7VKYpeGR4SM1okh4Q3JQzY39Yhwq0AJV2lElxefoJswMEmMVIhxxGVfHgirq/ACl l8EojL+PyPbtLAf2Wmww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jdcSZ-0007Ai-Hq; Tue, 26 May 2020 16:29:47 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jdcSX-00076n-BG for linux-arm-kernel@lists.infradead.org; Tue, 26 May 2020 16:29:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C352B30E; Tue, 26 May 2020 09:29:44 -0700 (PDT) Received: from [192.168.0.14] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C53183F52E; Tue, 26 May 2020 09:29:42 -0700 (PDT) From: James Morse Subject: Re: [PATCH 19/26] KVM: arm64: Make struct kvm_regs userspace-only To: Marc Zyngier References: <20200422120050.3693593-1-maz@kernel.org> <20200422120050.3693593-20-maz@kernel.org> Message-ID: <0a38305f-77f8-11b0-cb74-2bec07ce0a0a@arm.com> Date: Tue, 26 May 2020 17:29:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200422120050.3693593-20-maz@kernel.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200526_092945_437350_A973D910 X-CRM114-Status: GOOD ( 15.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kvm@vger.kernel.org, Suzuki K Poulose , Jintack Lim , Andre Przywara , Christoffer Dall , kvmarm@lists.cs.columbia.edu, Will Deacon , George Cherian , Julien Thierry , "Zengtao \(B\)" , Catalin Marinas , Alexandru Elisei , Dave Martin , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Marc, On 22/04/2020 13:00, Marc Zyngier wrote: > struct kvm_regs is used by userspace to indicate which register gets > accessed by the {GET,SET}_ONE_REG API. But as we're about to refactor > the layout of the in-kernel register structures, we need the kernel to > move away from it. > > Let's make kvm_regs userspace only, and let the kernel map it to its own > internal representation. > diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c > index 23ebe51410f06..9fec9231b63e2 100644 > --- a/arch/arm64/kvm/guest.c > +++ b/arch/arm64/kvm/guest.c > @@ -102,6 +102,55 @@ static int core_reg_size_from_offset(const struct kvm_vcpu *vcpu, u64 off) > return size; > } > > +static void *core_reg_addr(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) > +{ > + u64 off = core_reg_offset_from_id(reg->id); > + > + switch (off) { > + default: > + return NULL; Doesn't this switch statement catch an out of range offset, and a misaligned offset? ... We still test for those explicitly in the caller. Better safe than implicit? > + } > +} With the reset thing reported by Zenghui and Zengtao on the previous patch fixed: Reviewed-by: James Morse (otherwise struct kvm_regs isn't userspace-only!) Thanks, James _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel