From patchwork Wed Apr 20 21:42:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 12820834 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 DBC12C433F5 for ; Wed, 20 Apr 2022 21:44:36 +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:From:Subject:Mime-Version:Message-Id :Date:Reply-To: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=MLkJ8WCH+A6qw6l8YTpt+1SqM/YkGQQZmnWUlO4Wdas=; b=2xdD7ROJRfnRT9 eLuwYXjmEXcZay3uCdmGKCXSklsH15o1BBDqAyj0OcY556I//NSw3Rk/ageJowlFeKRoxI9O+f6R5 Yr3w2UIBcrVXk3fqiph4PLgOzHrSTI23d1rDyC+bE8+jEDAIpZ6Jn8d1Cg8VksRdAcAmvlPHjf8vE RuCzIG8vwuuk3uPzoc9QcXdc9WOKooGkusYaAR1bARRtgFsZEwK+avErZ7Dcye56Ws98ios+zF9wX a6g0EFyqPIwoiRo5p0+HF79aVltmi0KgOJV2vq7UFjXdvlAMzmYhnMXfoax9xM/wFtCgipSeTrDSS /1q7j3j5LQe5bJ3Yg7nw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhI6o-00ATuZ-Il; Wed, 20 Apr 2022 21:43:34 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhI6l-00ATtI-5X for linux-arm-kernel@lists.infradead.org; Wed, 20 Apr 2022 21:43:32 +0000 Received: by mail-yb1-xb49.google.com with SMTP id x7-20020a056902050700b00641671dc5d0so2652897ybs.18 for ; Wed, 20 Apr 2022 14:43:29 -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:cc; bh=+ofVstgby+3VUZOCrqyBENIw0S2XGlsTcYhm1RZdUZ8=; b=V7/nRf1aqIhn3GrpHT/lkZMBo6WJCgvRWtI4hC60Tae7j51kV7NX/30fPVFIT1ZkRi UKsROxDen1kXaLPU9eDlOYdcjYnozYuA1MnCV5aibXYS3U3bKc+BUjEJwkVwRxaK3hCB GGSVcC3uywSpPEm1PDWOTeFyI7qJnBk/oLORu10hqRdBr9k0nt570qWwaznIFNr2gmiw 8XjMBScKKSOI1Y+1Y77BNZ7MLZTkTJ13fqOIjHBAd6Rfx4XFYzh/TGqiQ6vNll2ZiYoS WRm5geb+q+v1x1QVSZEjNHe3dtSRAg2v4RqdKtcocsQgYo32gQqVgraqx9QT36kUhGkB Rg2g== 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:cc; bh=+ofVstgby+3VUZOCrqyBENIw0S2XGlsTcYhm1RZdUZ8=; b=2/NaWqIOC/MHzmnq24bsSzPx++BqWCMa/pQimYV0v5OFOOcd0+duEkSwQE53veJy6m YvTKsyPHv7QwTCE2H4HyH5wkJPhfjz7+8kF7E+mBFs/jM2N1rqTNDysAjbAZG5pUq1JH SrV52DPob9HZ7f26OmST6jZD9zcQYTahM8akW10UzrigJha8/pDyq31eQz21AtZxWQT6 /op3ideUF1pk3Nc4+ckDgA337dM+XAqbDeioa1bRGJ73DE0Z4OmA+4I7TwI+RqyU2yxo boIxLDs0Aa2yjGiJnXheBsu0EnXswgeEllH64QkBGeAVOjQPz/2GGQ3DgbD/9FPaloh+ oJtw== X-Gm-Message-State: AOAM53172CUk5h37UM+H11H7wIO7yEgXPQZdiKsS3IOYbJHcPXde2T+0 tuOdBXoXxwZW9EZf+KGhTrq59FudP2SNbrm+BQ== X-Google-Smtp-Source: ABdhPJynQJ6HrTNIms4xwX26QBfSuJVgQPazfDGqbIdwuqV/+SEBOChc4CyWeC3dRM3VwPtqGh5RY3jW3hVs31ZLaw== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:2a20:cec4:8f41:cd6f]) (user=kaleshsingh job=sendgmr) by 2002:a81:478b:0:b0:2ea:da8c:5c21 with SMTP id u133-20020a81478b000000b002eada8c5c21mr23887312ywa.189.1650491008962; Wed, 20 Apr 2022 14:43:28 -0700 (PDT) Date: Wed, 20 Apr 2022 14:42:51 -0700 Message-Id: <20220420214317.3303360-1-kaleshsingh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog Subject: [PATCH v8 0/6] KVM: arm64: Hypervisor stack enhancements From: Kalesh Singh Cc: will@kernel.org, maz@kernel.org, qperret@google.com, tabba@google.com, surenb@google.com, kernel-team@android.com, Kalesh Singh , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Mark Rutland , Ard Biesheuvel , Zenghui Yu , Nathan Chancellor , Masahiro Yamada , Changbin Du , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220420_144331_268270_E6952E98 X-CRM114-Status: GOOD ( 11.35 ) 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 all, This is v8 of the nVHE hypervisor stack enhancements. This version is based on 5.18-rc3. Previous versions can be found at: v7: https://lore.kernel.org/r/20220408200349.1529080-1-kaleshsingh@google.com/ v6: https://lore.kernel.org/r/20220314200148.2695206-1-kaleshsingh@google.com/ v5: https://lore.kernel.org/r/20220307184935.1704614-1-kaleshsingh@google.com/ v4: https://lore.kernel.org/r/20220225033548.1912117-1-kaleshsingh@google.com/ v3: https://lore.kernel.org/r/20220224051439.640768-1-kaleshsingh@google.com/ v2: https://lore.kernel.org/r/20220222165212.2005066-1-kaleshsingh@google.com/ v1: https://lore.kernel.org/r/20220210224220.4076151-1-kaleshsingh@google.com/ Thanks, Kalesh ----- This series is based on 5.18-rc3 and adds stack guard pages to nVHE and pKVM hypervisor; and symbolization of hypervisor addresses. The guard page stack overflow detection is based on the technique used by arm64 VMAP_STACK. i.e. the stack is aligned such that the 'stack shift' bit of any valid SP is 1. The 'stack shift' bit can be tested in the exception entry to detect overflow without corrupting GPRs. Kalesh Singh (6): KVM: arm64: Introduce hyp_alloc_private_va_range() KVM: arm64: Introduce pkvm_alloc_private_va_range() KVM: arm64: Add guard pages for KVM nVHE hypervisor stack KVM: arm64: Add guard pages for pKVM (protected nVHE) hypervisor stack KVM: arm64: Detect and handle hypervisor stack overflows KVM: arm64: Symbolize the nVHE HYP addresses arch/arm64/include/asm/kvm_asm.h | 1 + arch/arm64/include/asm/kvm_mmu.h | 3 ++ arch/arm64/kvm/arm.c | 37 +++++++++++-- arch/arm64/kvm/handle_exit.c | 13 ++--- arch/arm64/kvm/hyp/include/nvhe/mm.h | 6 ++- arch/arm64/kvm/hyp/nvhe/host.S | 24 +++++++++ arch/arm64/kvm/hyp/nvhe/hyp-main.c | 18 ++++++- arch/arm64/kvm/hyp/nvhe/mm.c | 78 ++++++++++++++++++---------- arch/arm64/kvm/hyp/nvhe/setup.c | 31 +++++++++-- arch/arm64/kvm/hyp/nvhe/switch.c | 7 ++- arch/arm64/kvm/mmu.c | 68 ++++++++++++++++-------- scripts/kallsyms.c | 3 +- 12 files changed, 220 insertions(+), 69 deletions(-) base-commit: b2d229d4ddb17db541098b83524d901257e93845