From patchwork Tue Oct 5 09:01:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12536007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5025FC43219 for ; Tue, 5 Oct 2021 09:06:00 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2805161371 for ; Tue, 5 Oct 2021 09:06:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2805161371 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=XtTmJyHfp4StcQDwsuEYAS9AljZXnoO6cLSP1KaywtE=; b=n4Z4mmwRP7aR885cQlpzpfZdC7 zk0mt5xYhNii5ompOBU5s22v2tf3/Cy0hCnOcd8zF2CiMxF5H8byiHEgW79gNjjzKQN4+cJFq7wSx motMezJRTnwT9sbuI31juK5azeJOpXmDgI5/ASGFifs4y3M3y/5wz9byyzh2rZcNrRI6JcwlBpPmD +jBMT1jZr4HS8oiUv4I4Nos+N4xuWw6yQFXMpUIoDZRCp24Biy+7m9zbW+6at0PoKMQ8bVDpRiF6Q ons+4wP54hm7b1ImDt0HuJ1lZleLDOkyAqJw2cj90otrgLhhRWjtGs8QTQNdnUJ/M+nHvj7cuCWTo +Tv719Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXgMg-009dxX-Sc; Tue, 05 Oct 2021 09:03:59 +0000 Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mXgM8-009dha-67 for linux-arm-kernel@lists.infradead.org; Tue, 05 Oct 2021 09:03:25 +0000 Received: by mail-wm1-x349.google.com with SMTP id o22-20020a1c7516000000b0030d6f9c7f5fso1577569wmc.1 for ; Tue, 05 Oct 2021 02:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=IJ5d9LFfxfsfjOyzMb9wAWVGNaAsBq4D1S2tLUmROQw=; b=k+C6KttgJIhWI0N6my6Gmd+ifempL0NxliApNM7bNFc4Zypp/266/edmPpEdSuDO6k BE90f8QW/H93+LTSCmLBuGx6sAqz7pvyDbd+uGNlrq2s33VlMhGlGZHNhEJGQskmS7Sq H3A4s6gUk4VgPHHkYEMLWraNS5mgRAPw+PZ4EBgI3WL0zgszOi1M00F1dadnofYdFWon FgyIwwZ5d7m1fgmZMM8TOnwJdR2xercMi9sTasNLWYOOCQ9DIzXjssEiSBg7PlQOcvX5 L2sCgUPBIptqZ2kWHkne6YuTtKba/WcDG0cGnwu/hL7rHcLbGW7NnTteqVrtdarf8XNk zYmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=IJ5d9LFfxfsfjOyzMb9wAWVGNaAsBq4D1S2tLUmROQw=; b=Gh8a0XvoGt0FKidkFFdHSM/RpQRSFH3A3jqCIgYbhscahDN+Vmtc9xcEFz4S8AQIdP o3HmyqTTVkE1OEyByaVzdh+jTnOvK7X65QNhw5j/8saIunaQDNmAQI7ZRPYbBLSfor3G zBIFvLuX27krKtvLlCvXGH8F3LJo1qPLQ0yZgtiGqIOCzVlMWHIES7/a99fq3/DNeUhz dMG1esIck3qKrWGE6gsbliYpnxUpKrE6ezWNYmzrrXiyLbpeD+/j7yJGUZqFKzGFdha4 hIb4kj5BWzgs1yNC3yZiuKNrj7xme+3gcaa/jSbTu+gtKIPgrxS/WdpySM67MFfntGqd gnTQ== X-Gm-Message-State: AOAM531/mFqqua5gHFqU77xmePDRna9AZZBbIy+vLePR/3+PYDIqgpSm 4R8DAbxAnve+h5cdJ7xLiAosY8JWMoqc X-Google-Smtp-Source: ABdhPJyWTqPJLcSZAfXhuyYllToltNQE4ex6rZPSYifRYSyemm303hl/IP70LZOn0VKNHsWefxffl1TuuHTX X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:5700:9128:3106:b389]) (user=qperret job=sendgmr) by 2002:a05:600c:3b26:: with SMTP id m38mr484791wms.0.1633424600779; Tue, 05 Oct 2021 02:03:20 -0700 (PDT) Date: Tue, 5 Oct 2021 10:01:42 +0100 In-Reply-To: <20211005090155.734578-1-qperret@google.com> Message-Id: <20211005090155.734578-6-qperret@google.com> Mime-Version: 1.0 References: <20211005090155.734578-1-qperret@google.com> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog Subject: [PATCH v2 2/2] KVM: arm64: Report corrupted refcount at EL2 From: Quentin Perret To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Quentin Perret , Fuad Tabba , David Brazdil , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Cc: kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211005_020324_259993_D517CE82 X-CRM114-Status: UNSURE ( 9.43 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some of the refcount manipulation helpers used at EL2 are instrumented to catch a corrupted state, but not all of them are treated equally. Let's make things more consistent by instrumenting hyp_page_ref_dec_and_test() as well. Acked-by: Will Deacon Suggested-by: Will Deacon Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kvm/hyp/nvhe/page_alloc.c b/arch/arm64/kvm/hyp/nvhe/page_alloc.c index a6e874e61a40..0bd7701ad1df 100644 --- a/arch/arm64/kvm/hyp/nvhe/page_alloc.c +++ b/arch/arm64/kvm/hyp/nvhe/page_alloc.c @@ -152,6 +152,7 @@ static inline void hyp_page_ref_inc(struct hyp_page *p) static inline int hyp_page_ref_dec_and_test(struct hyp_page *p) { + BUG_ON(!p->refcount); p->refcount--; return (p->refcount == 0); }