Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6470414ybl; Mon, 23 Dec 2019 06:26:41 -0800 (PST) X-Google-Smtp-Source: APXvYqzKzGCTttGQ/6Z0yjJBp6R+GIv5HigU81JEQPdHSJe4ai3VdguhSSroZlvgVs4Aswd+1rBp X-Received: by 2002:a9d:7f12:: with SMTP id j18mr34135333otq.17.1577111201130; Mon, 23 Dec 2019 06:26:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577111201; cv=none; d=google.com; s=arc-20160816; b=sdfnm/IjHwrBO1N5TBwy2XYL0dLCjWhTflfn3TraoGZYVb4k8nOjvxrbCKo+2MkssJ CQLqByQvR1qvvDG2mO3cKv3n2f4Y+froaKisToZ5tn6j8CA9FaIzpVjdiK3xdLBbIzsG oaOsZIxPwc/nN2nhsFEd6D4AWA3FzwRq0jX8t+lVWgXCIoTKrUBkrJRT2cxWMTRIJyhX t8Zm7WR6w0NW1bektwFbVv/gqMGFtq98GrlFtXMlKAXL+O8W/SR9ztVzqb1tqhGwdZYP 4qRc3vR1KhwpMrDZemVOQksNax+gmw0xxzoqdvnolsI9EBMBfrU8X78wcF6bCOjtYjLc yGQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=nTyEDFusLKumYW0h03qshyTMkbaeVnlSIDHnGUWtv+s=; b=tiiB+H0S83nu1fQQfHtuWiUCXcENvNlq5wfgOkEo+ve9b2SVGGWILd1hJylonJ3dcd xINS63Irq26Nwwf0Bzyg7ishW6KSFnzeiVYdg3p6+QVi6HT8Yoo+4ZmsbI1fTODfZZuj a76xvUlPmEHY63aKdFo3OimCkM1lfL2MOftD53VBaexTbhA6/4xKYHpRtrVn/ONsELOY IH8oe5Ap+x4q0aufIYw3DRo09qY5F2LyheeWZp5jB626wNeSqY2YgM3E0xoJPBXbjRAR 5DrC0j8bY+EdD0KuYeFc08xZXLgsrVjRMUSmJgIv/16Cl4bY7HP8HQwbpjSQTfxmAFsu 24cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VhXXQ7VW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b133si9672395oif.244.2019.12.23.06.26.28; Mon, 23 Dec 2019 06:26:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VhXXQ7VW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726853AbfLWOZs (ORCPT + 99 others); Mon, 23 Dec 2019 09:25:48 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:31871 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726763AbfLWOZr (ORCPT ); Mon, 23 Dec 2019 09:25:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577111147; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nTyEDFusLKumYW0h03qshyTMkbaeVnlSIDHnGUWtv+s=; b=VhXXQ7VWfTY1g5I5vAvKSVfaf07BwiCpmrL4/vV/o8Kjc6qAkwlVRzG0e/yT9+5m1XruQL fPc7h43StF4Urk9HB6TAdYDQ73q0jmQHOPoqizpKxLGY800HzT4+xN8ZlKHOB4++KJGd7x rWry44MErpple9KQVrkpA69WXvhPBCE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-49-eooe5S9dObea5djAYhn2sA-1; Mon, 23 Dec 2019 09:25:43 -0500 X-MC-Unique: eooe5S9dObea5djAYhn2sA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D36A11005502; Mon, 23 Dec 2019 14:25:41 +0000 (UTC) Received: from [10.36.116.117] (ovpn-116-117.ams2.redhat.com [10.36.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 54E7860BF4; Mon, 23 Dec 2019 14:25:37 +0000 (UTC) Subject: Re: [PATCH] KVM: arm/arm64: vgic: Handle GICR_PENDBASER.PTZ filed as RAZ From: Auger Eric To: Zenghui Yu , maz@kernel.org Cc: andre.przywara@arm.com, linux-kernel@vger.kernel.org, wanghaibin.wang@huawei.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org References: <20191220111833.1422-1-yuzenghui@huawei.com> <3a729559-d0eb-e042-d6bd-b69bacb0dd23@huawei.com> Message-ID: <4817b05f-1822-7fc7-99a5-e7d5deae1055@redhat.com> Date: Mon, 23 Dec 2019 15:25:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Zenghui, Marc, On 12/23/19 3:19 PM, Auger Eric wrote: > Hi Zenghui, >=20 > On 12/23/19 2:43 PM, Zenghui Yu wrote: >> On 2019/12/20 19:18, Zenghui Yu wrote: >>> Although guest will hardly read and use the PTZ (Pending Table Zero) >>> bit in GICR_PENDBASER, let us emulate the architecture strictly. >>> As per IHI 0069E 9.11.30, PTZ field is WO, and reads as 0. >>> >>> Signed-off-by: Zenghui Yu >>> --- >>> >>> Noticed when checking all fields of GICR_PENDBASER register. >>> But _not_ sure whether it's worth a fix, as Linux never sets >>> the PTZ bit before enabling LPI (set GICR_CTLR_ENABLE_LPIS). >>> >>> And I wonder under which scenarios can this bit be written as 1. >>> It seems difficult for software to determine whether the pending >>> table contains all zeros when writing this bit. >>> >>> =C2=A0 virt/kvm/arm/vgic/vgic-mmio-v3.c | 5 ++++- >>> =C2=A0 1 file changed, 4 insertions(+), 1 deletion(-) >>> >>> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c >>> b/virt/kvm/arm/vgic/vgic-mmio-v3.c >>> index 7dfd15dbb308..ebc218840fc2 100644 >>> --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c >>> +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c >>> @@ -414,8 +414,11 @@ static unsigned long >>> vgic_mmio_read_pendbase(struct kvm_vcpu *vcpu, >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 gpa_t addr, unsigned int len) >>> =C2=A0 { >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct vgic_cpu *vgic_cpu =3D &vcpu->a= rch.vgic_cpu; >>> +=C2=A0=C2=A0=C2=A0 u64 value =3D vgic_cpu->pendbaser; >>> =C2=A0 -=C2=A0=C2=A0=C2=A0 return extract_bytes(vgic_cpu->pendbaser, = addr & 7, len); >>> +=C2=A0=C2=A0=C2=A0 value &=3D ~GICR_PENDBASER_PTZ; >>> + >>> +=C2=A0=C2=A0=C2=A0 return extract_bytes(value, addr & 7, len); >>> =C2=A0 } >>> =C2=A0 =C2=A0 static void vgic_mmio_write_pendbase(struct kvm_vcpu *v= cpu, >>> >> >> I noticed there is no userspace access callbacks for GICR_PENDBASER, >> so this patch will make the PTZ field also 'Read As Zero' by userspace= . >> Should we consider adding a uaccess_read callback for GICR_PENDBASER >> which just returns the unchanged vgic_cpu->pendbaser to userspace? >> (Though this is really not a big deal. We now always emulate the PTZ >> field to guest as RAZ. And 'vgic_cpu->pendbaser & GICR_PENDBASER_PTZ' >> only indicates whether KVM will optimize the LPI enabling process, >> where Read As Zero indicates never optimize..) > You're right. If we start a migration when the PTZ has just been set by > the SW, then we will miss it on the destination side. >=20 > So for instance in the last KVM unit test of my series > (https://lore.kernel.org/kvmarm/20191216140235.10751-17-eric.auger@redh= at.com/), > in test_its_pending_migration(), if you kick the migration before > enabling LPI's at redist level, you shouldn't see any LPI hitting on th= e > target which is theoretically wrong. So implementing a uaccess_read() > would be better I think. >=20 > Thanks >=20 > Eric >=20 > + ptr =3D gicv3_data.redist_base[nr_cpus - 1] + GICR_PENDBASER; > + pendbaser =3D readq(ptr); > + writeq(pendbaser & ~GICR_PENDBASER_PTZ, ptr); > + > + ptr =3D gicv3_data.redist_base[nr_cpus - 2] + GICR_PENDBASER; > + pendbaser =3D readq(ptr); > + writeq(pendbaser & ~GICR_PENDBASER_PTZ, ptr); That's a clear actually. So Marc is right, forget what I have just said. This will work on destination size as we will write 0. Sorry for the noise Hopefully Christmas break is coming ;-) Best Regards Eric >=20 > + puts("Now migrate the VM, then press a key to continue...\n"); > + (void)getchar(); > + report(true, "Migration complete"); > + > + gicv3_rdist_ctrl_lpi(nr_cpus - 1, true); > + gicv3_rdist_ctrl_lpi(nr_cpus - 2, true); > + >> >> >> Thanks, >> Zenghui >> >> >> _______________________________________________ >> linux-arm-kernel mailing list >> linux-arm-kernel@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >>