Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8776290rwp; Wed, 19 Jul 2023 15:25:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGqxXad5cQVB7Zk8aSGxGLX+MJQeXzioLZUOMTpyVALixh2aLTGNqNsiOr2i3KiFHcKsKT9 X-Received: by 2002:a17:906:208d:b0:994:522f:3f4a with SMTP id 13-20020a170906208d00b00994522f3f4amr3394722ejq.29.1689805539067; Wed, 19 Jul 2023 15:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689805539; cv=none; d=google.com; s=arc-20160816; b=uzYpx0Cy440LBhsRMbAS7QP1Xw/B3CBa6OFOA9ARO6ALxFTIbaoBD9Fdfr6kGcHrg5 1tNhSr6Sn9Ck7/dC+mjqRCXtdxEfMWLWVimNB4Jj9TiRBWWgnx09kNYOJRIUlvZVIDns /K51aRCrsbWzgoSCXBV1IyzPafdZ0Bn2pr+HUCqZAYr40LAo7fI4XSNRcFu9R4o+Dc/E Z+grh93UaaL0j0QgdzAZyMkL4//1VY+Zh91fBtAF6AIKX2UeZXdfYAaY9yQcVeXcC5lU DrcPRPPcbLv3cQClRoK65W43ev1h1qddxS/e5yEixQe2W4kC3VAUaSmI3eJKo1V7q4wy F/Gw== 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:message-id:mime-version:date :dkim-signature; bh=d3Ht7L7dsVm5KYjvx2fbdO1jyBq4m055oYZLq1pDnXs=; fh=KTEx20bofIfHC4U0b3O5hp+kIf4hzWzzEbPhxCIwTfM=; b=m4inpsM8ZBsD5MQDkxdGO5nYkFadKLMa2lJ0B4DcA82NMjL1ughmrpOiTCaZWY8Ks6 s+bNRt9+0VHAJ9zx2aGW430Xyvz2md4Ond59GpXap1xsxZ21PfCJ7jPkg3RPDmo0FARZ UenhxbRWcq9afaxMVJW/4EvA2cmOM3WM8e57UGXFs4ASLhgDGG06UDIwJPl/ABa8m/NX gXMPRFNsiIuhEWZ4yGlSLzDnGZTEc1nWPVSTdSgrAWbdd8ubCW8K+m7AoqFM68T8f+pd o7nOHKoNQBtH827uPuDUKpw2vMMHuV+TSiwRlbKMRmWVhL23LWR+AAaDAVhRWfwqiMwu 2saQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Ra8+xJNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t25-20020a1709064f1900b00997ea7d6658si2368043eju.61.2023.07.19.15.25.14; Wed, 19 Jul 2023 15:25:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Ra8+xJNP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230052AbjGSV5c (ORCPT + 99 others); Wed, 19 Jul 2023 17:57:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbjGSV5a (ORCPT ); Wed, 19 Jul 2023 17:57:30 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F6321FD9 for ; Wed, 19 Jul 2023 14:57:29 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-c64ef5bde93so104326276.0 for ; Wed, 19 Jul 2023 14:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689803848; x=1690408648; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=d3Ht7L7dsVm5KYjvx2fbdO1jyBq4m055oYZLq1pDnXs=; b=Ra8+xJNP/sYgyLpaDBs1F288TIvL1tnzWLHFmnzM7/dQqrNn5YcbKDgTbFtPDZD/ha K8MFOKEa+OQyC87XpoOeppzZtaRCkoHPRaR+wC1YoKWuo1BAl875kJyfty5HOfA/hD9+ DfLJhptuW65V2HY78jzcImh3piPxWnQw9n9gcwz97bbRazS7jcez6cAmtuqzFBjG12+w mtv2cEj7lNF4fu2yhTlpdewK1595/OJ//S3L+ici78yhdckGjZky1+pC4CyEGkAidHWm IBziZwUK+XXVoHgvync2hHaby+uusAd+25S0ybYENq7qI1Wh9pAbi7wcu7J7bvZIarxv g/Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689803848; x=1690408648; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=d3Ht7L7dsVm5KYjvx2fbdO1jyBq4m055oYZLq1pDnXs=; b=GaUnipB2dsz3JA/+rXBv96n1yUJPDtfxSFL0/RMW8wZSACsuuB9KyqtURgbUOI9wCk Wa9v5gE6iSwjY4GCbZ8h/I5aCasJMNJUwxe76gd+BNxJRkIrHHNbc7oT6r02ynJ9c2J7 2mStDM769JF4rk3gG9Cbn7TlIUwADKhXr6hOEBMovBlCWw7ZNf8EjNsqEhTQ+zXEk8Lu jlS8KBMIkyVxCgRqn0TW3c6ifXKw4FUDXQVPOIoArD0i9t99sCPRBfXzBz+oNeXbjCfG pgky8SrSckJW9Kcnvwh03Qp33RzT98lN0abzRasx91bCD+xf/u6i95hMuslVH1FJybqL Ywgw== X-Gm-Message-State: ABy/qLZtuziXBCBUdN5oDuS4rx2/kqmwBglWjOqrXxtn+vg9VgQ85UGM 1hl97ar4suf2H7CmIHSvLYtTjc1grJPd X-Received: from rananta-linux.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:22b5]) (user=rananta job=sendgmr) by 2002:a5b:352:0:b0:cc7:b850:7f2 with SMTP id q18-20020a5b0352000000b00cc7b85007f2mr30000ybp.5.1689803848368; Wed, 19 Jul 2023 14:57:28 -0700 (PDT) Date: Wed, 19 Jul 2023 21:57:25 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog Message-ID: <20230719215725.799162-1-rananta@google.com> Subject: [PATCH v2] KVM: arm64: Fix hardware enable/disable flows for pKVM From: Raghavendra Rao Ananta To: Oliver Upton , Marc Zyngier Cc: James Morse , Suzuki K Poulose , Will Deacon , Fuad Tabba , Jing Zhang , Colton Lewis , Reiji Watanabe , Raghavendra Rao Anata , kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When running in protected mode, the hyp stub is disabled after pKVM is initialized, meaning the host cannot enable/disable the hyp at runtime. As such, kvm_arm_hardware_enabled is always 1 after initialization, and kvm_arch_hardware_enable() never enables the vgic maintenance irq or timer irqs. Unconditionally enable/disable the vgic + timer irqs in the respective calls, instead relying on the percpu bookkeeping in the generic code to keep track of which cpus have the interrupts unmasked. Fixes: 466d27e48d7c ("KVM: arm64: Simplify the CPUHP logic") Reported-by: Oliver Upton Suggested-by: Oliver Upton Signed-off-by: Raghavendra Rao Ananta --- arch/arm64/kvm/arm.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index c2c14059f6a8..010ebfa69650 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1867,14 +1867,10 @@ static void _kvm_arch_hardware_enable(void *discard) int kvm_arch_hardware_enable(void) { - int was_enabled = __this_cpu_read(kvm_arm_hardware_enabled); - _kvm_arch_hardware_enable(NULL); - if (!was_enabled) { - kvm_vgic_cpu_up(); - kvm_timer_cpu_up(); - } + kvm_vgic_cpu_up(); + kvm_timer_cpu_up(); return 0; } @@ -1889,10 +1885,8 @@ static void _kvm_arch_hardware_disable(void *discard) void kvm_arch_hardware_disable(void) { - if (__this_cpu_read(kvm_arm_hardware_enabled)) { - kvm_timer_cpu_down(); - kvm_vgic_cpu_down(); - } + kvm_timer_cpu_down(); + kvm_vgic_cpu_down(); if (!is_protected_kvm_enabled()) _kvm_arch_hardware_disable(NULL); -- 2.41.0.487.g6d72f3e995-goog