From patchwork Mon May 9 12:03:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 12843373 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 81E20C433FE for ; Mon, 9 May 2022 12:04:49 +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:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=xm1BaMJqE70wSugp0Ai7aqVo8YorhoaqD1ONQmrBNbU=; b=LNg W3egJ2GCgsNZJMU7C/Ia+zd9O0knaC3opLuQUr7kP67dXcSBgzRnIeug7BCToIhgJLMdFb51Exb1r YUHbKOR4XRgw+As4E/3M8PVVrkwisjLkWRrzpgZ6Rl0KaHYmI7fTbd58i6TP+TIjyr2V2Jq571gGS MljQ/+Ppm5mgOffmbZIaPqWtWcPQOL6+DnFA24bnP2A1IZyl1yJoW/QIUcbtXDY/nVzqFES7abAyD s7sIkMnYmjIB28WR/Bj1qfbLmXNi2KEWcl8D9B0qFrgcHvOOwHY0feAr8+nk7XMs7aSYWNLCNsRu0 Isw3AiOGs5589Bi/FomuiFcIFt6LyXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1no270-00EEKh-UJ; Mon, 09 May 2022 12:03:39 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1no26x-00EEJA-M2 for linux-arm-kernel@lists.infradead.org; Mon, 09 May 2022 12:03:37 +0000 Received: by mail-wr1-x449.google.com with SMTP id u11-20020a056000038b00b0020c9ea8b64fso4407516wrf.2 for ; Mon, 09 May 2022 05:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=YMy3zUpcEva0SvcO2znuocWV4BxelK38M/0ZkCce1/o=; b=oyRENR29svxIjW8y0bn+9l+tm6uheonymddtzfMmxTQpEIOXTLEhsuDoJurbpf9Dql dX3+CwctEskmdnCkpWbD3x+1cOCMMte1IwsfWGd53lKCUL6prr6o2eO6fgLqnv16iwQX 03jm0KF1s2/1JIqWRQm1cR6ruBfPMEtdBYU0Ye/1SZz8wWylHr73VrdvoCABDqeqEnjG J1LRR+rigz8Xa/Mpw4+E7EeCPWUg0QwYmRtQeDPJWdowSTH5OkzzWakvbhe1mTXevgkq /yavFDETEWOjUksc0HO+mBofLP0O/IerslGWCVmwI3nU2bEgoQ0q+rwK1avmEpeohVQb rZpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=YMy3zUpcEva0SvcO2znuocWV4BxelK38M/0ZkCce1/o=; b=WU2L/YAHaOUW2GjwBDy/QFGQ8AuupGfKwMYXVB8aGxdmaEIjwS2TMMSKbF3ZJUyFVD Baz7PObYVYrKHl5JZDbXad0KMfTjoysdOZD5SRKdxdQXcf7WSY3/HLptEaly30T7lLsH /HHuRh/vKQUOhozUv9akcrpI2AlJWuU8RhzF1Fl6VpeAZsla6kdvFNh26PACE9l558ff UmIJ3+zHmf5LXDQnJBiRxJtSwlWUR0YoMUeIPANNze9OevmBpkL+CEQojtuDubXdTXGZ tyttmg9CX7LmzdmOpvBH2NIYW/1tOwd/qaQLHUSYBnl1ZpMqwBHwXT5s87HzzZj80Iv+ /TVA== X-Gm-Message-State: AOAM532fF1kWFqU9xFWi0sTUPINpnYnxYf5qoLEv8LLAXyMXsTQBMDWO edsK2bT5am4Ozl4PPaiNuYVl7FeNFw== X-Google-Smtp-Source: ABdhPJx2gD40Jlpp+yqprlC3izQ6s8s7DSQKi5Tj7o72c7gpbpuKKc4mcoYD/msXCfnOYCYanpxgCuZG6g== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:adf:f58e:0:b0:20a:dfc8:f894 with SMTP id f14-20020adff58e000000b0020adfc8f894mr13461869wro.428.1652097812108; Mon, 09 May 2022 05:03:32 -0700 (PDT) Date: Mon, 9 May 2022 12:03:26 +0000 Message-Id: <20220509120330.3043773-1-tabba@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog Subject: [PATCH v3 0/4] KVM: arm64: Do not communicate host pmu event changes by accessing hyp data From: Fuad Tabba To: kvmarm@lists.cs.columbia.edu Cc: maz@kernel.org, will@kernel.org, qperret@google.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, drjones@redhat.com, linux-arm-kernel@lists.infradead.org, tabba@google.com, kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220509_050335_774958_C45344AB X-CRM114-Status: GOOD ( 10.94 ) 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 Hi, This series changes the way KVM communicates host pmu event changes to the hypervisor in nvhe and protected mode. Instead of accessing hyp data directly from the host, the data is passed to hyp via the loaded vcpu. This provides more isolation between the host and the hypervisor, and allows us to use pmu in protected mode. This series is based on kvmarm/next (8c22fd2d4cfa). Changes since V2 [1]: - Update the guest view of the pmu events after interrupts have been disabled Changes since V1 [2]: - Repack struct kvm_pmu to remove all (two) holes - Updating the guest's view of the pmu events before every vcpu run rather than vcpu load to avoid missing updates Thanks, /fuad [1] https://lore.kernel.org/all/20220509095500.2408785-1-tabba@google.com/ [2] https://lore.kernel.org/linux-arm-kernel/20220408084052.3310931-1-tabba@google.com/ Fuad Tabba (4): KVM: arm64: Wrapper for getting pmu_events KVM: arm64: Repack struct kvm_pmu to reduce size KVM: arm64: Pass pmu events to hyp via vcpu KVM: arm64: Reenable pmu in Protected Mode arch/arm64/include/asm/kvm_host.h | 8 ++----- arch/arm64/kvm/arm.c | 15 ++++++++++++ arch/arm64/kvm/hyp/nvhe/switch.c | 20 +++++----------- arch/arm64/kvm/pmu-emul.c | 3 +-- arch/arm64/kvm/pmu.c | 40 ++++++++++++++++++------------- include/kvm/arm_pmu.h | 10 ++++++-- 6 files changed, 55 insertions(+), 41 deletions(-) base-commit: 8c22fd2d4cfaab2ae3c5859496c894df58ab014b