Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6464481ybl; Mon, 23 Dec 2019 06:21:10 -0800 (PST) X-Google-Smtp-Source: APXvYqw1Ar40R8me7HJ5SGwegmcsqdi9VpN9lz9v9WNpSd6wkRdwXFCX69XWBq4f1Z/AhJMC1jaE X-Received: by 2002:a9d:461b:: with SMTP id y27mr35514512ote.280.1577110869900; Mon, 23 Dec 2019 06:21:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577110869; cv=none; d=google.com; s=arc-20160816; b=N94f1v8yCPReF2z7yzKIeKStAZDJpyAYiQPKwdmfWFE42Wrv/4QZ/Q6/Yrh0gwfY4H mfP7goNIdEliRG2gTgYrRqoOlerHJT3wy4rnItZez/dz/LHeGNw8b6XwxH7T5yjC7mrT s2fYKlDTW5lDdREOcggatNa1ck8qC+GrBXmeL3UVYzV3Rkv6gd92gvMs+BZYfloQvhIF Z6QI/imAbV6ANoUdE3/wzKHXeE6p3Bp1TNBKBSCa3P6G3xLOR+t9CtRcFjk2fq5+2zV2 CXJqrwXOKejZ/gK3wIhF92ngirYwvtxT3qqsXUYNmvTNPNPXqNlDXxpuBFE+0wZRh5fB GpHA== 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:from:references:cc:to:subject:dkim-signature; bh=mL7EP1HVEPCTfjY90+H+xu1r0sHEJd8rLQjw69yZex0=; b=fB9Q2pLfejGnGwJPHwpHJoFBTNl9pb+0EBuL1a53hCEhh1digm2y1Q+OMo/3dVw3J0 SDetmuAYSwpXnWZrJ7CMuOvlG9NhmAt74CPNMJs8Xc1NZy3z09YnPix3BCVnsdiduGAb crH5/TK2gjKrnKUs9uif8oSvdLrDGu8osmUcDHjc8rWT0kX+8aL0MGy7xTEELy9Pu0OQ dHsDrFx9bDlM4NKejVUYHqfpQBa0SLDYuPnuLkpklgQhs0GayjBL/WcLbHSEKfmU68Wk J+/Sz0EQgPL3i9XHJkw6WU4zfHLFLanQVm8J7MozJMs+qH/U8hzm3YJANzHN6TwAeHgs cehw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YoltEoUG; 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 n139si9667638oig.121.2019.12.23.06.20.57; Mon, 23 Dec 2019 06:21:09 -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=YoltEoUG; 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 S1727280AbfLWOTv (ORCPT + 99 others); Mon, 23 Dec 2019 09:19:51 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:34675 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726763AbfLWOTv (ORCPT ); Mon, 23 Dec 2019 09:19:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577110789; 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=mL7EP1HVEPCTfjY90+H+xu1r0sHEJd8rLQjw69yZex0=; b=YoltEoUGfMKNCh4WByfZc5tznAk0aoc6GikuNdl+A8NLeO0Kpmc/PdTP2FtgxBXVaENi3k tlALP0tBMnqU+FoBs0tGwBm1Bv3wMvAif81wNnyAVtzhn251Gb5AaCAhzf5uyKBVzq9J+7 ZsuDREyQ3f8NQaX/mvcnkUl45cvl8bg= 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-9-KzmNUHtbOzSZH2L4w0OQ9g-1; Mon, 23 Dec 2019 09:19:43 -0500 X-MC-Unique: KzmNUHtbOzSZH2L4w0OQ9g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 854A48017DF; Mon, 23 Dec 2019 14:19: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 4687A10375CC; Mon, 23 Dec 2019 14:19:35 +0000 (UTC) Subject: Re: [PATCH] KVM: arm/arm64: vgic: Handle GICR_PENDBASER.PTZ filed as RAZ 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> From: Auger Eric Message-ID: Date: Mon, 23 Dec 2019 15:19:30 +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: <3a729559-d0eb-e042-d6bd-b69bacb0dd23@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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, 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->ar= ch.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, a= ddr & 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 *vc= pu, >> >=20 > 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. So for instance in the last KVM unit test of my series (https://lore.kernel.org/kvmarm/20191216140235.10751-17-eric.auger@redhat= .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 the target which is theoretically wrong. So implementing a uaccess_read() would be better I think. Thanks Eric + 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); + 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); + >=20 >=20 > Thanks, > Zenghui >=20 >=20 > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >=20