Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6081669ybl; Sun, 22 Dec 2019 22:53:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxk5HOwWBia1YZYgPuVNXtcK7IQMzP9XQ27vY/IgnVcTG+2y3OzL9o+PeD5ZefECRx82wgB X-Received: by 2002:a9d:674f:: with SMTP id w15mr31534379otm.243.1577083986111; Sun, 22 Dec 2019 22:53:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577083986; cv=none; d=google.com; s=arc-20160816; b=1JNOo+I6HQKEedv9jZ/qfSH7KeRI8z6VSnAwhDHlnAGrFXZar+A0nQdw/wOCl7ZzlP Kg1S8q4aedL0vQqHlKgAL05LoWc/pfPGhNlc7Fp/bRbB7tK7IZT65r6hIdNHjx8rfud4 ekSKhDKd9udyb/uT71wkaaXqUofu8vsA+XPOlc08UZkU4DZqE7I3RtnOG5fN4zfoAWCO HFJRJKaag//q+TgbUFUAllT4NEgDOB235mREth/xTpes38Hf3Jbm7bXIjlWsU5/eqpsC dzfmYP/scVg8dCWkTbEetH0XF6nmRbgqMAtBiN8W+0eEUgrY5hM0WVd6I0hH2etuRLfa UR1Q== 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; bh=SHtb+zLAryxcu/5ZcnsO8m8nLaZiiSwlxmYelWV4SVQ=; b=QxddqO3xBR0/y/L3mLVngR6N1IlDLO+2w3yQkI4CIItmv5DI1/fOoGnzPXqIygp6VV OiTQDqvUqia2V3d1ViYMHjJaGUFE3CMaaLvmz1zAyvS0SjO+zIplxJKD/8y/swsZfn/N UTKLAUD28k3XTSOsABgTTn6qCfI8lThVRjYssXoMn/4IRY6RjY0RfwJXSoNRZZOPBkIX PfNAROZ1P6eOCz5kZRdkypqOC+FvF6E7XivFtDuv/iao98ckdLC8DtLqCzts5JUsh08r m5jlDynemA63UR/aZuVyMe95Flfz1JnpuA73ZnuQpUNW48MhYot4ZZ6P4TFEVDemjDlt 6kDg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v67si9456927oia.26.2019.12.22.22.52.52; Sun, 22 Dec 2019 22:53:06 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725974AbfLWGvC (ORCPT + 99 others); Mon, 23 Dec 2019 01:51:02 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:7728 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725810AbfLWGvC (ORCPT ); Mon, 23 Dec 2019 01:51:02 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 48FF52AF828E5AFB0898; Mon, 23 Dec 2019 14:51:00 +0800 (CST) Received: from [127.0.0.1] (10.173.222.27) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Mon, 23 Dec 2019 14:50:53 +0800 Subject: Re: [PATCH] KVM: arm/arm64: vgic: Handle GICR_PENDBASER.PTZ filed as RAZ To: Marc Zyngier , CC: , , , , References: <20191220111833.1422-1-yuzenghui@huawei.com> <71e3dcc00ad5ab8dffd732bfe7381705@www.loen.fr> From: Zenghui Yu Message-ID: <5f5f499a-d025-cc9f-66f3-37fe958df246@huawei.com> Date: Mon, 23 Dec 2019 14:50:51 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <71e3dcc00ad5ab8dffd732bfe7381705@www.loen.fr> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.173.222.27] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marc, Eric, On 2019/12/20 21:07, Marc Zyngier wrote: > On 2019-12-20 11: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. > > This is a useless HW optimization, where it can avoid reading the > pending table the very first time you write to this register if > it is told that it is all zero. A decent ITS implementation > already has a mechanism to find out about the pending bits by > looking into the IMPDEF area (the first 1kB) of the pending table. Yeah, AFAICT this is what Hisilicon has already implemented today. > PTZ is just yet another way to do the same thing. > > This can only happen once in the lifetime of the system (when allocating > the table), and Linux doesn't really care. I now get it, thanks for teaching me that! > As usual, the GIC is setting > the level of useless complexity pretty high... > >> >>  virt/kvm/arm/vgic/vgic-mmio-v3.c | 5 ++++- >>  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, >>                           gpa_t addr, unsigned int len) >>  { >>      struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; >> +    u64 value = vgic_cpu->pendbaser; >> >> -    return extract_bytes(vgic_cpu->pendbaser, addr & 7, len); >> +    value &= ~GICR_PENDBASER_PTZ; >> + >> +    return extract_bytes(value, addr & 7, len); >>  } >> >>  static void vgic_mmio_write_pendbase(struct kvm_vcpu *vcpu, > > Otherwise looks good. I'll queue it with Eric's correction > to the subject line. Thanks both and Merry Christmas! Zenghui