From patchwork Tue Dec 5 10:22:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13479888 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 58FA0C4167B for ; Tue, 5 Dec 2023 10:23:40 +0000 (UTC) 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:Message-ID: References:Mime-Version: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=ISB7Eu2dhmmkAFBcxa2Xy0XxiQM7Mt6rA8nvSC1ZfS4=; b=DbjWM+Y1tuzVf5puzAYhjeC4A6 HinfujlQ8xR0KNowW27EJrvpLL3Zk5kap7cbQ+VFmq+HnWo7S1AelQH6Dpp/k3bS9fC9tAYM27coB cpkfx/7MO17y7QI4dts/hnzpwMItzjIiPqr9a3/EAccYHMagId03XnGCWAwk+pdUUw9o225Jbui2Z lvRgOrnvWEyR910d2VOQa0Q6gLm2lLnwwgL0WM+iWhJx/2hMwRhWOaSH9ftYFSWrjN9rcRVTZNh8m 2qLXmiw0OzH43tCiQWC2qdp1+CxOLCYxtUH0v7HiK+kNDjQyQ0Fx4iA1gPSlo74SyQEXS0txA/lEB TPibNR4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rASa4-006xWY-1V; Tue, 05 Dec 2023 10:23:08 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rASa1-006xSG-1N for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 10:23:06 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-3334e56554bso1373377f8f.0 for ; Tue, 05 Dec 2023 02:23:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701771782; x=1702376582; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Nsl2YYWjzyWfpOqWiIYZWMEIY6Tqfa70sHcibcvmU8U=; b=vjh5n5sch2mD1pRJQ//tUU+z1/AhypWKC+m41gtOyvIDTP9hAwOZsZNqkC1SbNX94b EMhsFLEesFJwAeJ0YZxPwyNzXbZ5fOszsbiZJW2kXHEOvzRsVKiRIdjcKMjcoqV3UgoB r0kcrn6lnnWAUbByqmkTgaRY1xBGiJv54QutGvIUXlIhXiyZZvNT62Z9s6v53WdxOyU9 hWoxcZLkmASLl6IodabGI18LH+A/MAIXE9BZ4Qeehv1HJ9uLzKepsFqop8fHAbg3ZaAj 2dXZ5vA+Cwxwf6xMMaHl8vhqxf1IpYL1HiRQZjOsKSRrbT2mv3oG2j+Dobogn8F+m3lw AoYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701771782; x=1702376582; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Nsl2YYWjzyWfpOqWiIYZWMEIY6Tqfa70sHcibcvmU8U=; b=TwY9o+Ko/JTkRFIVTUO3xtU2mSdaoSr4uogbbwTXIbGSYfvftHxTxs0m364P5KDlEZ ydYsTLG2oOdITUhZiq9nXTWoz9eq1iU1zT0bk/97sUf3eiswz1KHmsdpfK8CmUKkjYAW PhexXJ1Wjv0MI5/jf2mV17Fj+mxRIN1J2Tjsm2brkvDOpkHm+4b36DT3PTE0tazEFvFH uDfjKoxezeVblYP/mqfUs69ovY027B0qcUhO20FEUWJOMSHqpbzsnxEss3hnBo6Smn6/ KqRaq+3AHcKCB6BkK3FIn3O48NUKcLXmNxs7ygogkSI+WXqhH/acazy0C1w2wO+8wgFw KHHw== X-Gm-Message-State: AOJu0YzRBYNIAqHBjZ6XpYeVQ7UUY3OIl9ZGG6yPvPWwUX4usP4o21Fn IoKi+czMdaQE0Wd6p5MJdfBCXj2QLg== X-Google-Smtp-Source: AGHT+IGc3JXd4AZGnIIfddtzEYdRl3d3707t9Y6hVwx3FZAfMEmHj/ndlXJo0QeFYZ+zl2D7AFOfbmNFow== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:adf:fd90:0:b0:333:32d8:40a5 with SMTP id d16-20020adffd90000000b0033332d840a5mr116120wrr.7.1701771782375; Tue, 05 Dec 2023 02:23:02 -0800 (PST) Date: Tue, 5 Dec 2023 10:22:47 +0000 In-Reply-To: <20231205102248.1915895-1-tabba@google.com> Mime-Version: 1.0 References: <20231205102248.1915895-1-tabba@google.com> X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Message-ID: <20231205102248.1915895-6-tabba@google.com> Subject: [PATCH v1 5/6] KVM: arm64: Trap external trace for protected VMs From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231205_022305_473342_7CB6C49A X-CRM114-Status: GOOD ( 11.04 ) 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 pKVM does not support external trace for protected VMs. Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/nvhe/pkvm.c | 4 ++++ arch/arm64/tools/sysreg | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index 9d23a51d7f75..84b5c3f387d8 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -136,6 +136,10 @@ static void pvm_init_traps_aa64dfr0(struct kvm_vcpu *vcpu) cptr_set |= CPTR_EL2_TTA; } + /* Trap External Trace */ + if (!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64DFR0_EL1_ExtTrcBuff), feature_ids)) + mdcr_clear |= MDCR_EL2_E2TB_MASK << MDCR_EL2_E2TB_SHIFT; + vcpu->arch.mdcr_el2 |= mdcr_set; vcpu->arch.mdcr_el2 &= ~mdcr_clear; vcpu->arch.cptr_el2 |= cptr_set; diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg index 96cbeeab4eec..02e1a4290fa5 100644 --- a/arch/arm64/tools/sysreg +++ b/arch/arm64/tools/sysreg @@ -1115,7 +1115,10 @@ Enum 63:60 HPMN0 0b0000 UNPREDICTABLE 0b0001 DEF EndEnum -Res0 59:56 +UnsignedEnum 59:56 ExtTrcBuff + 0b0000 NI + 0b0001 IMP +EndEnum UnsignedEnum 55:52 BRBE 0b0000 NI 0b0001 IMP