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 Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B407C43334 for ; Tue, 19 Jul 2022 13:30:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 871964CB70; Tue, 19 Jul 2022 09:30:26 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1mmF9zlxaInF; Tue, 19 Jul 2022 09:30:25 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 55ECD4CB56; Tue, 19 Jul 2022 09:30:25 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id AF5CF4CB4A for ; Tue, 19 Jul 2022 09:30:23 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T1aKzgrSRa6W for ; Tue, 19 Jul 2022 09:30:22 -0400 (EDT) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 477C44C8C3 for ; Tue, 19 Jul 2022 09:30:22 -0400 (EDT) Received: by mail-wr1-f45.google.com with SMTP id h17so21663436wrx.0 for ; Tue, 19 Jul 2022 06:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=aeU9cgOyyIosd32FJcgD+fpFlGUSWOLfdLntVffrwYI=; b=hux2JLvdiv0cwO+vggf9NbJXBqDg2Ko8RqWrIxcttc9Hg0kU7gZtV0HtaGsYzMJN5r 2xw+PCxakX3m3q/UPEjcRkRQGRkSeFJ2fEGDqyoqsTV9ixkD9v22Id1hMmzBNtUiDsV3 Kop16VLrqGjXK9trmzw+2iuf+R8SFC6k5cm5xvtgAuXyR91yLdQxFt2Hks/xD4SMcbkv RpHxN4o4uYg7HOFYDEMnt50EWgUaPHUff6hQbVOVbFrvUGHzC8sDXcIeXO3S3TfcfB5Z L1h4cAf1nwg7RFdkmLR5r6js+oMs8hZj+72cbkaDTBShuQV8VpQ63RwhZpWHg6bc1V60 GlHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aeU9cgOyyIosd32FJcgD+fpFlGUSWOLfdLntVffrwYI=; b=XS1Rpwy6UD/UE6wxAqhWMJqP0avKK50ipPa8b+OVLbw0F2naOVsYEDMosxSo6WA94m btiu0UKiq7j5wkyCjfT04/0xcuZb0eONxEKyt82DKcmVXKiRO8uqbCWvVPw8XJMBVhu/ MDsJc3MiNJgtKHSZ9vKY1b45ptMbC/xq1yBJU1wS+Rj+x7qd3oRq+/zEKR8KjqXwugWV SnPSGA2ZrUWWp+ftvcuLyHudwZ1sm7bTbFH+lbZYZNBshjoKiSnAXV7zWu4ACyeSXJir OQgJhFpIq8/C6GHiIKaeEo4+x4bu0Tz8Ae7V1pHclYKskqwI6eNSRUyUQpdEbZmOZiJs JB+A== X-Gm-Message-State: AJIora+rP4c8Q7PxfjtP3H0MLXP/tN7rTtXU3z2xfk7qTvu8XmJRDWtZ JQf5Hj8UHx2ldlGbp501PylQgg== X-Google-Smtp-Source: AGRyM1vzvLKgd/6l5pxRFRCv0etdl5tPYv3bpkSlMQO5Lp/Wf3UVXLnmW9wvqkKhdX+dMbee37E47A== X-Received: by 2002:a05:6000:1541:b0:21d:b298:96be with SMTP id 1-20020a056000154100b0021db29896bemr26549092wry.206.1658237421084; Tue, 19 Jul 2022 06:30:21 -0700 (PDT) Received: from google.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id b14-20020a5d40ce000000b0021a56cda047sm13475885wrq.60.2022.07.19.06.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 06:30:20 -0700 (PDT) Date: Tue, 19 Jul 2022 14:30:16 +0100 From: Vincent Donnefort To: Will Deacon Subject: Re: [PATCH v2 14/24] KVM: arm64: Add pcpu fixmap infrastructure at EL2 Message-ID: References: <20220630135747.26983-1-will@kernel.org> <20220630135747.26983-15-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220630135747.26983-15-will@kernel.org> Cc: Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, Oliver Upton , Andy Lutomirski , linux-arm-kernel@lists.infradead.org, Michael Roth , Catalin Marinas , Chao Peng , kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu > static struct hyp_pool host_s2_pool; > diff --git a/arch/arm64/kvm/hyp/nvhe/mm.c b/arch/arm64/kvm/hyp/nvhe/mm.c > index d3a3b47181de..17d689483ec4 100644 > --- a/arch/arm64/kvm/hyp/nvhe/mm.c > +++ b/arch/arm64/kvm/hyp/nvhe/mm.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -24,6 +25,7 @@ struct memblock_region hyp_memory[HYP_MEMBLOCK_REGIONS]; > unsigned int hyp_memblock_nr; > > static u64 __io_map_base; > +static DEFINE_PER_CPU(void *, hyp_fixmap_base); > > static int __pkvm_create_mappings(unsigned long start, unsigned long size, > unsigned long phys, enum kvm_pgtable_prot prot) > @@ -212,6 +214,76 @@ int hyp_map_vectors(void) > return 0; > } > > +void *hyp_fixmap_map(phys_addr_t phys) > +{ > + void *addr = *this_cpu_ptr(&hyp_fixmap_base); > + int ret = kvm_pgtable_hyp_map(&pkvm_pgtable, (u64)addr, PAGE_SIZE, > + phys, PAGE_HYP); > + return ret ? NULL : addr; > +} > + > +int hyp_fixmap_unmap(void) > +{ > + void *addr = *this_cpu_ptr(&hyp_fixmap_base); > + int ret = kvm_pgtable_hyp_unmap(&pkvm_pgtable, (u64)addr, PAGE_SIZE); > + > + return (ret != PAGE_SIZE) ? -EINVAL : 0; > +} > + I probably missed something but as the pagetable pages for this mapping are pined, it seems impossible (currently) for this call to fail. Maybe a WARN_ON would be more appropriate, especially the callers in the subsequent patches do not seem to check for this function return value? [...] _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 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 7E057C433EF for ; Tue, 19 Jul 2022 13:31: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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=UyHANaID7kuRMLGGE8NWzglktN2Py/RX73OE66f+er0=; b=oJxPmIWbqEeJYe +kwYqaAWg4nQLaNiJaUhy/DFhra5qbhT3qk0xcA7Z2lkDrF9Fr7+JftRC2AUVlz670wXvY7aduTjP gEIMVrK8QLtN36DMUoEIbBAYeTlGZs+BWfKTssT3pqbrDyqLjTWxCdp8YDBxunXYOOTU4Ju8jRqUZ jIVHnVqE6VU4w3g5weuLHQIfrqiOpxAMfb5pwPnK3pVXkS/zPDp71rIcINP9ANxNl3s5j03J4zK7T Z/hsvEX8DIQPVPDuGo22ZqShUt+/D2VmlYxpdaTpHhxVA5hxL2p3rQQVh8frCTa09ATkLnGfwJUQQ IeaszdmRjslIFd+aDWAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDnJ0-009DI3-0F; Tue, 19 Jul 2022 13:30:30 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oDnIx-009DDQ-D9 for linux-arm-kernel@lists.infradead.org; Tue, 19 Jul 2022 13:30:28 +0000 Received: by mail-wr1-x42d.google.com with SMTP id z13so2030432wro.13 for ; Tue, 19 Jul 2022 06:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=aeU9cgOyyIosd32FJcgD+fpFlGUSWOLfdLntVffrwYI=; b=hux2JLvdiv0cwO+vggf9NbJXBqDg2Ko8RqWrIxcttc9Hg0kU7gZtV0HtaGsYzMJN5r 2xw+PCxakX3m3q/UPEjcRkRQGRkSeFJ2fEGDqyoqsTV9ixkD9v22Id1hMmzBNtUiDsV3 Kop16VLrqGjXK9trmzw+2iuf+R8SFC6k5cm5xvtgAuXyR91yLdQxFt2Hks/xD4SMcbkv RpHxN4o4uYg7HOFYDEMnt50EWgUaPHUff6hQbVOVbFrvUGHzC8sDXcIeXO3S3TfcfB5Z L1h4cAf1nwg7RFdkmLR5r6js+oMs8hZj+72cbkaDTBShuQV8VpQ63RwhZpWHg6bc1V60 GlHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aeU9cgOyyIosd32FJcgD+fpFlGUSWOLfdLntVffrwYI=; b=tP/PpeNltEvy28iqir0qBWiI3Vo4bzS+vJ4lK3atPd7df3j2dS9areCIaJzFypj0GT rfRplZxVYyDkyEt0TqbPjzxKQzjqPC+O6R7dm3YX64I/2J08eU/VS5KesOO42fnXzdoP 8ceMQe9zraQ0gQTQLB1VcInRspAVopWBybtLvuY//PLd+Fde+Bs78187XByFhfJA6G9k RU5zP8teFP2bvJss+DLG9s6pxqMfascYBEjS8Z9Fa3KDVqDyUdZ76kkVAcWe2IdF+caU Ms0gpE666xFuLXMH3KAHLdx+IWhWEhimHvt/0dlstBq/LP+KcoOLRTwIMgxbTvsUXn7Z /osQ== X-Gm-Message-State: AJIora9sX+TH8iIS9JxXx5WNHMOEWuN+cR8OSMZr8BBBSfHcj7h6xpW8 OZ92RDY/n1tGalCXrCRsWx3+VQ== X-Google-Smtp-Source: AGRyM1vzvLKgd/6l5pxRFRCv0etdl5tPYv3bpkSlMQO5Lp/Wf3UVXLnmW9wvqkKhdX+dMbee37E47A== X-Received: by 2002:a05:6000:1541:b0:21d:b298:96be with SMTP id 1-20020a056000154100b0021db29896bemr26549092wry.206.1658237421084; Tue, 19 Jul 2022 06:30:21 -0700 (PDT) Received: from google.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id b14-20020a5d40ce000000b0021a56cda047sm13475885wrq.60.2022.07.19.06.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 06:30:20 -0700 (PDT) Date: Tue, 19 Jul 2022 14:30:16 +0100 From: Vincent Donnefort To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, Ard Biesheuvel , Sean Christopherson , Alexandru Elisei , Andy Lutomirski , Catalin Marinas , James Morse , Chao Peng , Quentin Perret , Suzuki K Poulose , Michael Roth , Mark Rutland , Fuad Tabba , Oliver Upton , Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 14/24] KVM: arm64: Add pcpu fixmap infrastructure at EL2 Message-ID: References: <20220630135747.26983-1-will@kernel.org> <20220630135747.26983-15-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220630135747.26983-15-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220719_063027_480363_33D05016 X-CRM114-Status: GOOD ( 15.23 ) 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: , 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 > static struct hyp_pool host_s2_pool; > diff --git a/arch/arm64/kvm/hyp/nvhe/mm.c b/arch/arm64/kvm/hyp/nvhe/mm.c > index d3a3b47181de..17d689483ec4 100644 > --- a/arch/arm64/kvm/hyp/nvhe/mm.c > +++ b/arch/arm64/kvm/hyp/nvhe/mm.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -24,6 +25,7 @@ struct memblock_region hyp_memory[HYP_MEMBLOCK_REGIONS]; > unsigned int hyp_memblock_nr; > > static u64 __io_map_base; > +static DEFINE_PER_CPU(void *, hyp_fixmap_base); > > static int __pkvm_create_mappings(unsigned long start, unsigned long size, > unsigned long phys, enum kvm_pgtable_prot prot) > @@ -212,6 +214,76 @@ int hyp_map_vectors(void) > return 0; > } > > +void *hyp_fixmap_map(phys_addr_t phys) > +{ > + void *addr = *this_cpu_ptr(&hyp_fixmap_base); > + int ret = kvm_pgtable_hyp_map(&pkvm_pgtable, (u64)addr, PAGE_SIZE, > + phys, PAGE_HYP); > + return ret ? NULL : addr; > +} > + > +int hyp_fixmap_unmap(void) > +{ > + void *addr = *this_cpu_ptr(&hyp_fixmap_base); > + int ret = kvm_pgtable_hyp_unmap(&pkvm_pgtable, (u64)addr, PAGE_SIZE); > + > + return (ret != PAGE_SIZE) ? -EINVAL : 0; > +} > + I probably missed something but as the pagetable pages for this mapping are pined, it seems impossible (currently) for this call to fail. Maybe a WARN_ON would be more appropriate, especially the callers in the subsequent patches do not seem to check for this function return value? [...] _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D77FCC433EF for ; Tue, 19 Jul 2022 14:11:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239123AbiGSOL1 (ORCPT ); Tue, 19 Jul 2022 10:11:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239050AbiGSOLC (ORCPT ); Tue, 19 Jul 2022 10:11:02 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA56B491F3 for ; Tue, 19 Jul 2022 06:30:22 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id j1so17140215wrs.4 for ; Tue, 19 Jul 2022 06:30:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=aeU9cgOyyIosd32FJcgD+fpFlGUSWOLfdLntVffrwYI=; b=hux2JLvdiv0cwO+vggf9NbJXBqDg2Ko8RqWrIxcttc9Hg0kU7gZtV0HtaGsYzMJN5r 2xw+PCxakX3m3q/UPEjcRkRQGRkSeFJ2fEGDqyoqsTV9ixkD9v22Id1hMmzBNtUiDsV3 Kop16VLrqGjXK9trmzw+2iuf+R8SFC6k5cm5xvtgAuXyR91yLdQxFt2Hks/xD4SMcbkv RpHxN4o4uYg7HOFYDEMnt50EWgUaPHUff6hQbVOVbFrvUGHzC8sDXcIeXO3S3TfcfB5Z L1h4cAf1nwg7RFdkmLR5r6js+oMs8hZj+72cbkaDTBShuQV8VpQ63RwhZpWHg6bc1V60 GlHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aeU9cgOyyIosd32FJcgD+fpFlGUSWOLfdLntVffrwYI=; b=LqOvA85BR0KR89bs++rY5bu4+xyWwr5XKyGpGlIPFjJdTRysW4IHw4gNNsad85Lfmm OqPFyK29/r7v3v0IN9LpDS0kV3UU87Fex2rR5bw+wf/ertj07NOsIDHJ7EEuQWEt0hAO R6vfL3RyM7yqYYpfF+9l40+6mnLNDDSJgHNnm5ehFFcxK6V+RnxahxWNr9cWeUqWFVwO ZN+dGQaRMDSjX6yTTHYCij7sTxKooopq7BlOqzEy2IIMv8RZmiRr3qpHhpJbGngJfkgH r0hnIubCtvnaRjX26zXWkOHrIhhqS3uedHvLW0KMv9NornmuOfh+bmqlEhWynDNcL7t7 v0PA== X-Gm-Message-State: AJIora8d++GhYVr6qTcQEXOQv0wqqet48lYgj+mHo6JUPoMr8EYNtY5o cs6PkcAvjGOOYxeeHuPaSFKAqg== X-Google-Smtp-Source: AGRyM1vzvLKgd/6l5pxRFRCv0etdl5tPYv3bpkSlMQO5Lp/Wf3UVXLnmW9wvqkKhdX+dMbee37E47A== X-Received: by 2002:a05:6000:1541:b0:21d:b298:96be with SMTP id 1-20020a056000154100b0021db29896bemr26549092wry.206.1658237421084; Tue, 19 Jul 2022 06:30:21 -0700 (PDT) Received: from google.com (109.36.187.35.bc.googleusercontent.com. [35.187.36.109]) by smtp.gmail.com with ESMTPSA id b14-20020a5d40ce000000b0021a56cda047sm13475885wrq.60.2022.07.19.06.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jul 2022 06:30:20 -0700 (PDT) Date: Tue, 19 Jul 2022 14:30:16 +0100 From: Vincent Donnefort To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, Ard Biesheuvel , Sean Christopherson , Alexandru Elisei , Andy Lutomirski , Catalin Marinas , James Morse , Chao Peng , Quentin Perret , Suzuki K Poulose , Michael Roth , Mark Rutland , Fuad Tabba , Oliver Upton , Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 14/24] KVM: arm64: Add pcpu fixmap infrastructure at EL2 Message-ID: References: <20220630135747.26983-1-will@kernel.org> <20220630135747.26983-15-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220630135747.26983-15-will@kernel.org> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org > static struct hyp_pool host_s2_pool; > diff --git a/arch/arm64/kvm/hyp/nvhe/mm.c b/arch/arm64/kvm/hyp/nvhe/mm.c > index d3a3b47181de..17d689483ec4 100644 > --- a/arch/arm64/kvm/hyp/nvhe/mm.c > +++ b/arch/arm64/kvm/hyp/nvhe/mm.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -24,6 +25,7 @@ struct memblock_region hyp_memory[HYP_MEMBLOCK_REGIONS]; > unsigned int hyp_memblock_nr; > > static u64 __io_map_base; > +static DEFINE_PER_CPU(void *, hyp_fixmap_base); > > static int __pkvm_create_mappings(unsigned long start, unsigned long size, > unsigned long phys, enum kvm_pgtable_prot prot) > @@ -212,6 +214,76 @@ int hyp_map_vectors(void) > return 0; > } > > +void *hyp_fixmap_map(phys_addr_t phys) > +{ > + void *addr = *this_cpu_ptr(&hyp_fixmap_base); > + int ret = kvm_pgtable_hyp_map(&pkvm_pgtable, (u64)addr, PAGE_SIZE, > + phys, PAGE_HYP); > + return ret ? NULL : addr; > +} > + > +int hyp_fixmap_unmap(void) > +{ > + void *addr = *this_cpu_ptr(&hyp_fixmap_base); > + int ret = kvm_pgtable_hyp_unmap(&pkvm_pgtable, (u64)addr, PAGE_SIZE); > + > + return (ret != PAGE_SIZE) ? -EINVAL : 0; > +} > + I probably missed something but as the pagetable pages for this mapping are pined, it seems impossible (currently) for this call to fail. Maybe a WARN_ON would be more appropriate, especially the callers in the subsequent patches do not seem to check for this function return value? [...]