Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8575631ybi; Tue, 23 Jul 2019 11:03:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDyG3E4mtKiQDRbK0nBVSgR2uUUi3Z340C6oOXMmOiILEXg9kC8N5MsZ4oF8BgcXMX2XUZ X-Received: by 2002:a62:e315:: with SMTP id g21mr7262823pfh.225.1563904987077; Tue, 23 Jul 2019 11:03:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563904987; cv=none; d=google.com; s=arc-20160816; b=iUS2U2nQ1c3Bi9up6H+VujpqVVFlwXSWMUPGCsGw+fA3jyjpR7YLJcKjDISubEBZGL wuQmHjBoVF1rip4sxO15Er1O8/kYtq9tETh/ClzwXkT6OrTiQHkzbB6jmFz9zYcwsWVl VOJZ33oatJw3c2dyZ1xFB+SnnC3+6szIVjuwYGZGwY31a+iJnF7POKd57640MsXyQ5z4 gZhUKLzE5S3ihgtXbAIMZ/V40b9yxu+1vvHuT3k7KcKPnGWemKUO5k3US+fwrjoQbrKx n/UDjrQuVFOusXhsGr7vEK4hjtZTrOpb7n5rGpEHFdaw0LqCpiP5sDpPiLBlKnF/OzUW zELg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:cc:from:date:content-transfer-encoding:mime-version :subject:to; bh=F3N/FzEY7nnbKBDIKM0wnKGBve5IaF025fIVl7OeqqA=; b=UQeE7C/n+II4ZZLWqyGETWLdDaqmoNuqZ1N8wGNGaFV1OUzlLRe19zZhDWHVaRSidO 87zuw9/vMhH+Fzc86XtiNWe0at6PNQ39ayXVWFt3dDkMIRlHznGGtYy7HCjsM8F0cEMD YLb4/Q9wX85NlpAoUy1O4r4NbKQtIiwSkLRB4wD3MjOZYuFUewF6FiaPEMpUY3THaCp0 Gwll1DEAv6pDWhbbCaNSBxq+7EMquEU7uYeTKpTk8J5a665ql1JZr7nMG0cmWWaO+oNn Kq0nFFgYVTfcydRzShXVCWZUsEmKIJeRwArQjPF883FxuH4Df5rMRa+UBJa4TxXd9NwL /bsw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i24si17025116pgh.224.2019.07.23.11.02.51; Tue, 23 Jul 2019 11:03:07 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387785AbfGWJBq (ORCPT + 99 others); Tue, 23 Jul 2019 05:01:46 -0400 Received: from inca-roads.misterjones.org ([213.251.177.50]:59981 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387734AbfGWJBp (ORCPT ); Tue, 23 Jul 2019 05:01:45 -0400 X-Greylist: delayed 2135 seconds by postgrey-1.27 at vger.kernel.org; Tue, 23 Jul 2019 05:01:45 EDT Received: from www-data by cheepnis.misterjones.org with local (Exim 4.80) (envelope-from ) id 1hpq7Z-0006kD-Aa; Tue, 23 Jul 2019 10:26:05 +0200 To: Julien Thierry Subject: Re: [PATCH v2] KVM: arm/arm64: Introduce =?UTF-8?Q?kvm=5Fpmu=5Fvc?= =?UTF-8?Q?pu=5Finit=28=29=20to=20setup=20PMU=20counter=20idx?= X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 23 Jul 2019 09:26:04 +0100 From: Marc Zyngier Cc: Zenghui Yu , , , , , , , , In-Reply-To: References: <1563437710-30756-1-git-send-email-yuzenghui@huawei.com> Message-ID: X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/0.7.2 X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: julien.thierry@arm.com, yuzenghui@huawei.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, julien.thierry.kdev@gmail.com, linux-kernel@vger.kernel.org, wanghaibin.wang@huawei.com, andrew.murray@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-07-23 09:17, Julien Thierry wrote: > Hi Zenghui, > > On 18/07/2019 09:15, Zenghui Yu wrote: >> We use "pmc->idx" and the "chained" bitmap to determine if the pmc >> is >> chained, in kvm_pmu_pmc_is_chained(). But idx might be >> uninitialized >> (and random) when we doing this decision, through a >> KVM_ARM_VCPU_INIT >> ioctl -> kvm_pmu_vcpu_reset(). And the test_bit() against this >> random >> idx will potentially hit a KASAN BUG [1]. >> >> In general, idx is the static property of a PMU counter that is not >> expected to be modified across resets, as suggested by Julien. It >> looks more reasonable if we can setup the PMU counter idx for a vcpu >> in its creation time. Introduce a new function - kvm_pmu_vcpu_init() >> for this basic setup. Oh, and the KASAN BUG will get fixed this way. >> >> [1] https://www.spinics.net/lists/kvm-arm/msg36700.html >> >> Fixes: 80f393a23be6 ("KVM: arm/arm64: Support chained PMU counters") >> Suggested-by: Andrew Murray >> Suggested-by: Julien Thierry >> Cc: Marc Zyngier >> Signed-off-by: Zenghui Yu >> --- >> >> Changes since v1: >> - Introduce kvm_pmu_vcpu_init() in vcpu's creation time, move the >> assignment of pmc->idx into it. >> - Thus change the subject. The old one is "KVM: arm/arm64: Assign >> pmc->idx before kvm_pmu_stop_counter()". >> >> Julien, I haven't collected your Acked-by into this version. If >> you're >> still happy with the change, please Ack again. Thanks! >> > > Thanks for making the change. This looks good to me: > > Acked-by: Julien Thierry Applied, thanks both. M. -- Jazz is not dead. It just smells funny...