From patchwork Thu Feb 10 22:41:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 12742495 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 4E757C433F5 for ; Thu, 10 Feb 2022 22:44:50 +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:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BnNgmqorGOnCXCvOzaNqz+UBZ7QI+TQw9Ji8k3cezcw=; b=eva12BjUJRFuyr 0xgN2wsDSRxTMajknxw/zjegOCWGTVhKTVStI3vZE8NsYAbx6lvkCxXHQv8wzWT06dBgNPPhDp+4W Nl9nzLvRJTfc3IL8C1MO6pCJ6MDUHWp62C4rsBWCA0JB1n/NXihyBF1pvnbDLVEa/kPz88iMEqntq ndjnW+Je+KixvGHRFJcEYQd3zFGgXsgjjQ74LIY+Rq77VVVYOmEO4Ctvxgrv7OK/ncT64SaphmcQI zhEudMutaLtX1BGdcoTkbwRswNLozJifv5uKb9hlSFTsSA+PLC+T45HfxlfRlNKKCkLP5su/Nj3cm QAAe47mqBeEcfmt5KEBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nII9x-0053Iw-GH; Thu, 10 Feb 2022 22:43:29 +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 1nII9u-0053Ha-4t for linux-arm-kernel@lists.infradead.org; Thu, 10 Feb 2022 22:43:27 +0000 Received: by mail-yb1-xb49.google.com with SMTP id x1-20020a25a001000000b0061c64ee0196so15101514ybh.9 for ; Thu, 10 Feb 2022 14:43:25 -0800 (PST) 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:cc; bh=2CtdKKtWqmoQwaNtCKVnEnSlCVes5hG5Of9ZJoRSPvY=; b=nf4mRr3ZycGHhBqUZ+8DH8ok/Qz5Vau89sI8kQL6TBzahsS+36PcxWkEHapQEi57zC CGZbN1pSxbTcmxo4AB+1siE6sFbVo2nb0UNYy50fVpf34U/KaE2hkYTprUDL4Nb7cEx7 eOnLgbr0qMZnT6YgUCkRnP6o+xccxEE8H2B8bDpfPqwt3rT5owKtKDyzxlxoreRzy07y MzXYO5kYEYUKhF9/9jypyALGVa3urJxqTXcX0FAUfDebx61o/y7NyiNP7UOwQhkI7CzS luqBAqd7jIqdj7/5zwZd4zwMLB9kJDCIHLmkKLXY+xR7ATa7MbmSjWRxP0IbgVTg4WA9 yOBA== 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:cc; bh=2CtdKKtWqmoQwaNtCKVnEnSlCVes5hG5Of9ZJoRSPvY=; b=XYpQnksc1jcFQuWJbWcNuOUZBCq/1oyKFEY11i2I3xjR3mjOxE+XaXXcR6Fn5YuKNr b5jxPsqicezw2ZJhHDIx2qmo487nd/ObmhcdXgAyC+Mbliudsr16oNMRLBw/v80q3acg 6oJoGla6xOvL7aNiw3YRqkdL3t/Z3U1LobgsvCyTLks8rcrLfzHx5vZT80fB4QrBgdIS wvmdlK9cRUi5K6EkRBHOv5hAIhg1cxrIa+nPyVWhtXqlrlb//Ng4zEFaGJU9I8x4SBm2 lEEYKSMWajNyd9dGdMut6j5vdL+zzHmwamHfoq8uTNtCcFumqZ0mRMqSyiu0aMJACi6e 1Urg== X-Gm-Message-State: AOAM532hBmkGF8RlMOor8NxTaGYBhqJp5zp3dWIbp8BIoQR+j7gI2mIt eRZWaP8GJyQESeetzqMWjPA1kLkcMyZK5aWq6g== X-Google-Smtp-Source: ABdhPJwyMEA3/vPtnC5hrjc0C911vwYkTGYEzvGOgFv+0i9iJplYrKuXB9UfmBJoHZPA2fyRMmEXZHP0MgIOdqb77g== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:8f02:232:ad86:2ab2]) (user=kaleshsingh job=sendgmr) by 2002:a81:60c3:: with SMTP id u186mr9342666ywb.26.1644533004795; Thu, 10 Feb 2022 14:43:24 -0800 (PST) Date: Thu, 10 Feb 2022 14:41:42 -0800 In-Reply-To: <20220210224220.4076151-1-kaleshsingh@google.com> Message-Id: <20220210224220.4076151-2-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220210224220.4076151-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog Subject: [PATCH 1/7] KVM: arm64: Map the stack pages in the 'private' range 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 , Catalin Marinas , James Morse , Alexandru Elisei , Suzuki K Poulose , Ard Biesheuvel , Mark Rutland , Pasha Tatashin , Joey Gouly , Peter Collingbourne , Andrew Walbran , Andrew Scull , Paolo Bonzini , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_144326_213661_F2EC7102 X-CRM114-Status: GOOD ( 12.95 ) 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 From: Quentin Perret In preparation for introducing guard pages for the stacks, map them in the 'private' range of the EL2 VA space in which the VA to PA relation is flexible when running in protected mode. Signed-off-by: Quentin Perret [Kalesh - Refactor, add comments, resolve conflicts, use __pkvm_create_private_mapping()] Signed-off-by: Kalesh Singh --- arch/arm64/kvm/hyp/nvhe/setup.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c index 27af337f9fea..99e178cf4249 100644 --- a/arch/arm64/kvm/hyp/nvhe/setup.c +++ b/arch/arm64/kvm/hyp/nvhe/setup.c @@ -105,11 +105,19 @@ static int recreate_hyp_mappings(phys_addr_t phys, unsigned long size, if (ret) return ret; - end = (void *)per_cpu_ptr(&kvm_init_params, i)->stack_hyp_va; + /* Map stack pages in the 'private' VA range */ + end = (void *)__hyp_pa(per_cpu_ptr(&kvm_init_params, i)->stack_hyp_va); start = end - PAGE_SIZE; - ret = pkvm_create_mappings(start, end, PAGE_HYP); - if (ret) - return ret; + start = (void *)__pkvm_create_private_mapping((phys_addr_t)start, + PAGE_SIZE, PAGE_HYP); + if (IS_ERR_OR_NULL(start)) + return PTR_ERR(start); + end = start + PAGE_SIZE; + /* + * Update stack_hyp_va to the end of the stack page's + * allocated 'private' VA range. + */ + per_cpu_ptr(&kvm_init_params, i)->stack_hyp_va = (unsigned long) end; } /*