From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3164C433E0 for ; Thu, 4 Feb 2021 14:27:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 776D164F3C for ; Thu, 4 Feb 2021 14:27:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 776D164F3C Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3kBCHgTUS8OtVQ3ILOini+D1fq/EQvQ00l4sY4uwxcM=; b=s34gikSEs7AZ/5AuNj6MphaiE x+b5NNmETxt2pC26BoNxtBqk6iMNW44L9mkjMlRMXNTOX9HxhvAaKTtV8MnLiOGXwRzxrtFqIcsYo Fz9NjqW8s7rxBvL0pW/UdwxduxgitxeDCjCIErpDZDlA1g80zKEtmq4fv+UpS2NL9MD+SVHR9K5RQ AO6mJXuU+5T4nHy2DtUYim8oHChFe5GedbX0lMS0NO6ZBTkQ/cWnSHzDmA0giAYcAuf1dqF98rVRY YFQetn1IoIEt75/f01i3O0AoMvMJlBXuIlXfQBCA56GpMIH9gVb5XR1Tz2UdPVzt0qXdoXvxnMmc+ NIE7tZrhQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7fak-0002M8-Ee; Thu, 04 Feb 2021 14:26:42 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l7fah-0002LM-T5 for linux-arm-kernel@lists.infradead.org; Thu, 04 Feb 2021 14:26:40 +0000 Received: by mail-wm1-x32e.google.com with SMTP id 190so3305626wmz.0 for ; Thu, 04 Feb 2021 06:26:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WHxuqsEXEN4au8FdhV49UEllGtCSQh/DCdcron9InCc=; b=Pg47DSWBlJxWDTyOy0uhMGzKVxdYFLXQWQS0K5+zxLWQojmzL5h6ffmzz8z8JphFg+ GGQnNvn4zYaBYDPyC6oVULe1wxqtXA5XmivtJVmAw1gi3hAHI9cxbYJ8QeLjDxBqhN2z sfjDy3JiEEXoc6s37Q0mTdakrkoM5BHiSvuWBi3o11isnRp8muh/HasfGTLX1h7INMPE eu5FT15vPLlyQyL95luBYGKr7scOfYg8dDnnK/YcunKE0eaIWI/fCuGuv0YDlc808WV5 I+uMW4rSIiz6w0P13aivINkdIWrIx32dUc9bZPEOpmtG5xjHFd+ejnKzad1gnP1Q9wvP 8ztg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WHxuqsEXEN4au8FdhV49UEllGtCSQh/DCdcron9InCc=; b=cQ4bByTvDZavdV0cUK5Ck0Gvyrim+I7CXW42ZGWm+gzt7v0J+aIVmJZ4wL3y9Q3SV+ zulnsNHnvE/L03+nThVgEvI6ptt5rbFPthHMZ7dti1H6ZoEAHHqPAYIsa8AvuYlMz3dC vAfvc7+hrorexltV1e1KzzDMTwADQdRR/03BYUCu6aNvGmJ8TE/BLVREea3jzTwfxULo wkROJVEXYPUXSLyqpaj+FiqnuY38AnfDIo1cDQRhmNW6tq14+So10VltbpyrHd90ATit q7xogApgR2iSJ0cvlies2rzqO2uz1L8hR+q5Q5p7+VCB4v1BJFcUxGRIISd5rVcPnO2y Iakg== X-Gm-Message-State: AOAM5328WRYpDJf9MkNQRKj6eO2JBbSqAcLPl7Ee03tTdiSs7Ou8MpWD nKbbEaUZBKfj918yVMmGF28kng== X-Google-Smtp-Source: ABdhPJz8JyfdFBQ/Eq1UMUYtaCSGJYG+KqzKASSPlnHSKDldVsKHnk3I1lXTriVT3KNvdGryo6FBXw== X-Received: by 2002:a05:600c:4f13:: with SMTP id l19mr7619926wmq.70.1612448798327; Thu, 04 Feb 2021 06:26:38 -0800 (PST) Received: from google.com (230.69.233.35.bc.googleusercontent.com. [35.233.69.230]) by smtp.gmail.com with ESMTPSA id u3sm9286516wre.54.2021.02.04.06.26.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 06:26:37 -0800 (PST) Date: Thu, 4 Feb 2021 14:26:35 +0000 From: Quentin Perret To: Will Deacon Subject: Re: [RFC PATCH v2 26/26] KVM: arm64: Wrap the host with a stage 2 Message-ID: References: <20210108121524.656872-1-qperret@google.com> <20210108121524.656872-27-qperret@google.com> <20210203161146.GJ18974@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210203161146.GJ18974@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210204_092640_000591_FDE77062 X-CRM114-Status: GOOD ( 21.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, kernel-team@android.com, Suzuki K Poulose , android-kvm@google.com, Catalin Marinas , Fuad Tabba , linux-kernel@vger.kernel.org, Rob Herring , James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , David Brazdil , Frank Rowand , kvmarm@lists.cs.columbia.edu, Julien Thierry Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wednesday 03 Feb 2021 at 16:11:47 (+0000), Will Deacon wrote: > On Fri, Jan 08, 2021 at 12:15:24PM +0000, Quentin Perret wrote: > > When KVM runs in protected nVHE mode, make use of a stage 2 page-table > > to give the hypervisor some control over the host memory accesses. At > > the moment all memory aborts from the host will be instantly idmapped > > RWX at stage 2 in a lazy fashion. Later patches will make use of that > > infrastructure to implement access control restrictions to e.g. protect > > guest memory from the host. > > > > Signed-off-by: Quentin Perret > > --- > > arch/arm64/include/asm/kvm_cpufeature.h | 2 + > > arch/arm64/kernel/image-vars.h | 3 + > > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 33 +++ > > arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- > > arch/arm64/kvm/hyp/nvhe/hyp-init.S | 1 + > > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 6 + > > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 191 ++++++++++++++++++ > > arch/arm64/kvm/hyp/nvhe/setup.c | 6 + > > arch/arm64/kvm/hyp/nvhe/switch.c | 7 +- > > arch/arm64/kvm/hyp/nvhe/tlb.c | 4 +- > > 10 files changed, 248 insertions(+), 7 deletions(-) > > create mode 100644 arch/arm64/kvm/hyp/include/nvhe/mem_protect.h > > create mode 100644 arch/arm64/kvm/hyp/nvhe/mem_protect.c > > [...] > > > +void handle_host_mem_abort(struct kvm_cpu_context *host_ctxt) > > +{ > > + enum kvm_pgtable_prot prot; > > + u64 far, hpfar, esr, ipa; > > + int ret; > > + > > + esr = read_sysreg_el2(SYS_ESR); > > + if (!__get_fault_info(esr, &far, &hpfar)) > > + hyp_panic(); > > + > > + prot = KVM_PGTABLE_PROT_R | KVM_PGTABLE_PROT_W | KVM_PGTABLE_PROT_X; > > + ipa = (hpfar & HPFAR_MASK) << 8; > > + ret = host_stage2_map(ipa, PAGE_SIZE, prot); > > Can we try to put down a block mapping if the whole thing falls within > memory? Yes we can! And in fact we can do that outside of memory too. It's queued for v3 already, so stay tuned ... :) Thanks, Quentin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel