Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3429019pxb; Mon, 4 Oct 2021 02:09:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG8IeMztrp6QYvBFDl6x5laL0KdYArNng4WWLfnQQHjo/u5TjCN36ehk3Mj5RrHOTZTKMH X-Received: by 2002:a17:906:63ca:: with SMTP id u10mr15802908ejk.411.1633338546903; Mon, 04 Oct 2021 02:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633338546; cv=none; d=google.com; s=arc-20160816; b=I2v9zcKJx5GRZ4jMWltlzvYTNLNQMV9T20OtT6tC8iCxSshj8JFmG5OiMkmmPQvN0L hvEIV83lMhynx5pRl4X9+Z0gCG4SVuz8E8Xo7R+SgUzxRSd4OPRq/gfy4LjLqS5/clQ0 tI6k1teFz3sq1G0bfmQUpYEoR4ExM4xWRAmWQ8fTq9NQXBed45HBbzhBQ3HoQe8AXuyS EZaT7OVOa12pMUcrQvy5KhP1F1jIF/DVa/+M/hZzOtJIeqbEwYpnEnMaEUKr2AkmmNKl pvmi3TjgdZTg8VcRl4Hh0PYjx1ZLx9ToS76Ua7JxJcJxfjfS83h3i3KD4COZEDuz4XLd KySQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=wkyuiZINwNBLMyCf2gjjqTHN+Go0IESaSFToIb6F4Fw=; b=GJnxVihdA4XUvBQqB7p9Nh8vhYSIXIRdb6kSjKJbtUFN2AKEPAzowseIi41XtEUvmZ fjU2fX1j+C2uGxviW7gwjIF2aR6r/rUngni23G1dbrg1xiABIZAh4YZ2mx8ygDzmhqiV QlIyhmI+beHUP76WxnkxXAaTLi9KeLumfLf2jUS5MpuZ7exhMPOlTBJj3ydeA5L3XSPV kByKK0d13Wf49drf0y3JsQZT6mqfJYlQscMoRdPeHuYDGb7obOjN8JYAFeG5MVoiBqbf JfBl/CaeHtvjan9Ljr+fp85PSOOM9+FFSZJvD94HnfItXavbgC5xsL0cP2KPuUHv+lD/ +8Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TMjOfQHc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o3si18848066edc.246.2021.10.04.02.08.43; Mon, 04 Oct 2021 02:09:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TMjOfQHc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231575AbhJDJGI (ORCPT + 99 others); Mon, 4 Oct 2021 05:06:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231607AbhJDJGC (ORCPT ); Mon, 4 Oct 2021 05:06:02 -0400 Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11377C061745 for ; Mon, 4 Oct 2021 02:04:14 -0700 (PDT) Received: by mail-qv1-xf4a.google.com with SMTP id kc13-20020a056214410d00b00382bc805781so5865046qvb.12 for ; Mon, 04 Oct 2021 02:04:14 -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=wkyuiZINwNBLMyCf2gjjqTHN+Go0IESaSFToIb6F4Fw=; b=TMjOfQHcr/Buzl+oIVWhFVyiArxE1cZ3vpKMWyLANeP2U9TxY8SYN5pke9uBTQYz+U RIB1ZRrnPZHnfENtF9YmVzL5b2dsm+8nezApYrkcELyYsTgIxCXqXNO1hgtl+kxWOHqt YYimqCXssd0CsMUdzG3aiDaPHuW0jO1FRRSQN9CmPVoQKROHZ0soqL+iSp+ePqyxkxJ4 aBBfUHuRZy/2zMpYKVQ68s/iuanxLmWb85P3CroP0EVlbrCmCoq91Okjk9cJ5jEAWbgt MbAZGlaksbCy17axlm5ayqNk85VH9Kb4lIdjYPdiad/U6IoxI4yhM1WcNa0iTDKHwSHP B1ow== 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=wkyuiZINwNBLMyCf2gjjqTHN+Go0IESaSFToIb6F4Fw=; b=nnoqzkXmm7jEA5a/ouVH5gJCtSmfZIfSGTZ6i1+PEzI2k0gDmmgPe96TJwHI9QmkTN TFWkmqcaGcd9CHyj1Blut3uBLWHZ0zMXvcsUY/uzvOhNU4pI9ILaGXNC3CIXydMjqGJ4 4ubAjMYKC7jdK3ZKr14+5ZWsqLpNc/2ZlHHNzmcHN2GM0zxd1zaHhXMwBrvrG9cFXikX O76bXCPlMTsczJHLGho3b4WynHxbHxPQM605maFo94Cl3qI37LTBqKt4488dpt5Ouu1F 0pEJD9IkzeNemJO8rRGLEYhKA2VcvluEa2X8VaoGwC2hcuBXVK3LbRABTzIa0DGn4ec0 tv1Q== X-Gm-Message-State: AOAM530z5IxwX0uFB1SLP5J+Lgg4P3xJFABEmGpMdcTXoVaHfzwWeuyk BLs06XtYXt9o7/ZuBTGS/PBfQaWj6/Tj X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:669b:5b16:60b7:a3d4]) (user=qperret job=sendgmr) by 2002:a0c:85e6:: with SMTP id o93mr21326866qva.16.1633338253264; Mon, 04 Oct 2021 02:04:13 -0700 (PDT) Date: Mon, 4 Oct 2021 10:03:14 +0100 In-Reply-To: <20211004090328.540941-1-qperret@google.com> Message-Id: <20211004090328.540941-3-qperret@google.com> Mime-Version: 1.0 References: <20211004090328.540941-1-qperret@google.com> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog Subject: [PATCH 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some of the refcount manipulation helpers used at EL2 are instrumented to catch a corrupt 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. 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); } -- 2.33.0.800.g4c38ced690-goog