From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoffer Dall Subject: Re: [PATCH v4 07/10] KVM: arm/arm64: vgic: Return error on incompatible uaccess GICD_IIDR writes Date: Tue, 17 Jul 2018 11:10:50 +0200 Message-ID: <20180717091050.GB30570@e113682-lin.lund.arm.com> References: <1531746387-7033-1-git-send-email-christoffer.dall@arm.com> <1531746387-7033-8-git-send-email-christoffer.dall@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Marc Zyngier , Andre Przywara , "kvmarm@lists.cs.columbia.edu" , "linux-arm-kernel@lists.infradead.org" , "kvm@vger.kernel.org" To: Bharat Bhushan Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu List-Id: kvm.vger.kernel.org On Mon, Jul 16, 2018 at 03:43:28PM +0000, Bharat Bhushan wrote: > Hi Christoffer, > > > -----Original Message----- > > From: kvmarm-bounces@lists.cs.columbia.edu [mailto:kvmarm- > > bounces@lists.cs.columbia.edu] On Behalf Of Christoffer Dall > > Sent: Monday, July 16, 2018 6:36 PM > > To: kvmarm@lists.cs.columbia.edu; linux-arm-kernel@lists.infradead.org > > Cc: kvm@vger.kernel.org; Marc Zyngier ; Andre > > Przywara > > Subject: [PATCH v4 07/10] KVM: arm/arm64: vgic: Return error on > > incompatible uaccess GICD_IIDR writes > > > > If userspace attempts to write a GICD_IIDR that does not match the > > kernel version, return an error to userspace. The intention is to allow > > implementation changes inside KVM while avoiding silently breaking > > migration resulting in guests not running without any clear indication > > of what went wrong. > > > > Signed-off-by: Christoffer Dall > > --- > > virt/kvm/arm/vgic/vgic-mmio-v2.c | 21 ++++++++++++++++++--- > > virt/kvm/arm/vgic/vgic-mmio-v3.c | 21 ++++++++++++++++++--- > > 2 files changed, 36 insertions(+), 6 deletions(-) > > > > diff --git a/virt/kvm/arm/vgic/vgic-mmio-v2.c b/virt/kvm/arm/vgic/vgic- > > mmio-v2.c > > index db646f1..4f0f2c4 100644 > > --- a/virt/kvm/arm/vgic/vgic-mmio-v2.c > > +++ b/virt/kvm/arm/vgic/vgic-mmio-v2.c > > @@ -75,6 +75,20 @@ static void vgic_mmio_write_v2_misc(struct kvm_vcpu > > *vcpu, > > } > > } > > > > +static int vgic_mmio_uaccess_write_v2_misc(struct kvm_vcpu *vcpu, > > + gpa_t addr, unsigned int len, > > + unsigned long val) > > +{ > > + switch (addr & 0x0c) { > > I am just understanding the code, not sure if it make sense to replace hardcoded "0x0c". > We could encode it, but we use the hardcoded value elsewhere so I just followed the current pattern. Thanks, -Christoffer From mboxrd@z Thu Jan 1 00:00:00 1970 From: christoffer.dall@arm.com (Christoffer Dall) Date: Tue, 17 Jul 2018 11:10:50 +0200 Subject: [PATCH v4 07/10] KVM: arm/arm64: vgic: Return error on incompatible uaccess GICD_IIDR writes In-Reply-To: References: <1531746387-7033-1-git-send-email-christoffer.dall@arm.com> <1531746387-7033-8-git-send-email-christoffer.dall@arm.com> Message-ID: <20180717091050.GB30570@e113682-lin.lund.arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Mon, Jul 16, 2018 at 03:43:28PM +0000, Bharat Bhushan wrote: > Hi Christoffer, > > > -----Original Message----- > > From: kvmarm-bounces at lists.cs.columbia.edu [mailto:kvmarm- > > bounces at lists.cs.columbia.edu] On Behalf Of Christoffer Dall > > Sent: Monday, July 16, 2018 6:36 PM > > To: kvmarm at lists.cs.columbia.edu; linux-arm-kernel at lists.infradead.org > > Cc: kvm at vger.kernel.org; Marc Zyngier ; Andre > > Przywara > > Subject: [PATCH v4 07/10] KVM: arm/arm64: vgic: Return error on > > incompatible uaccess GICD_IIDR writes > > > > If userspace attempts to write a GICD_IIDR that does not match the > > kernel version, return an error to userspace. The intention is to allow > > implementation changes inside KVM while avoiding silently breaking > > migration resulting in guests not running without any clear indication > > of what went wrong. > > > > Signed-off-by: Christoffer Dall > > --- > > virt/kvm/arm/vgic/vgic-mmio-v2.c | 21 ++++++++++++++++++--- > > virt/kvm/arm/vgic/vgic-mmio-v3.c | 21 ++++++++++++++++++--- > > 2 files changed, 36 insertions(+), 6 deletions(-) > > > > diff --git a/virt/kvm/arm/vgic/vgic-mmio-v2.c b/virt/kvm/arm/vgic/vgic- > > mmio-v2.c > > index db646f1..4f0f2c4 100644 > > --- a/virt/kvm/arm/vgic/vgic-mmio-v2.c > > +++ b/virt/kvm/arm/vgic/vgic-mmio-v2.c > > @@ -75,6 +75,20 @@ static void vgic_mmio_write_v2_misc(struct kvm_vcpu > > *vcpu, > > } > > } > > > > +static int vgic_mmio_uaccess_write_v2_misc(struct kvm_vcpu *vcpu, > > + gpa_t addr, unsigned int len, > > + unsigned long val) > > +{ > > + switch (addr & 0x0c) { > > I am just understanding the code, not sure if it make sense to replace hardcoded "0x0c". > We could encode it, but we use the hardcoded value elsewhere so I just followed the current pattern. Thanks, -Christoffer