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 DBDECC4332F for ; Tue, 18 Oct 2022 16:41:28 +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=um/9k/r0uehzCAuKDpuEqbPGgd/8OIOUJavvyck4k7U=; b=0Ua+TmDp1wfu6W 5lxCTuZ21aGx2uz1AmvaqJvuYC3fjJYrOPEukGmZciC1GafBuODX1OCbGdmuUCiu5eKb3tSkGnHVO fOh6uHpI9FkRtD527Lx5yL0MyLmceSwv8iwWH0NJjdf8RXO+Ram2XtWVygL8NQpVFg2Ld+0I7eJi2 YLTSYGBcWk/dYQB1dtIpsCvcSpXKuvDlRJhG4940fbTvnjH9pIBm5qJOY7fEbSxN4h17k5mm+F7Uz gEYTnXL6Bfi0hqZ5yc/XZDBXOAGijvXqjaHbZ0UzVhoo0u6i3UDvRIoT/nc60//b7OyOTjMnxIVvf FehgCgj7Wtm6O6XqfUxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1okpdf-008ylc-Qe; Tue, 18 Oct 2022 16:40:23 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1okpdc-008yi6-QP for linux-arm-kernel@lists.infradead.org; Tue, 18 Oct 2022 16:40:22 +0000 Received: by mail-ed1-x530.google.com with SMTP id m15so21305859edb.13 for ; Tue, 18 Oct 2022 09:40:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=iOPA6fmSUQtvOcvu63Z4VIuGCcRSbgkai17AnO42Xg8=; b=RwOSzwSlFSbCd7ZBY+OuXxbAjYHeUdWktNJRobH9SE1tBqo+ITG+S/2lqQ99WtmZGg 2aklvAWwCrZAx0WH3PgMsnj83COBQ8EHzUnN/XJ7xG6IsbY5W8R5VFOWceL//p/6rYJV uIPytEw9UgH8/6EUaPS0RF+l5QZ1XgcJsIVQdyGngbNT6vPQuI/xdHCUv3ucc95MOCFB /4X/44neCUuawCWgVLmlYyyt+MG8/pNfDjmANn88qH8rDWp0Ve4Y8GCi9bLi51hWzpdz iDkB1tzuk46gjKvZYbU/sTHqsHpFLI3l87eHYe5xINvdWGxUBpfjq52o1EBlMeIiWQsq tWiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iOPA6fmSUQtvOcvu63Z4VIuGCcRSbgkai17AnO42Xg8=; b=000Z+xLjLl1l9lEW5m8j12vl8NtcaY6AQV1NoDn7NU/Md/4g3R2TVd6FJoesWAduVR T8cyXqYdw2h3khHayVuaWGoeUc6gcPWW0yU9gchr9X4nNukWY14bho7N8QZnR8OAnrSl 5PaiRSZxEAPHfIjceXz7noMlFv2HwG6mGy6b9chLp8i/buzbtWsw1uLIERVZZyVRgzF2 AGxnQI4jsT/FUazBVOaSbDAkMrX7sXaZviUSLa0xcPPOJtmnOdujtPWi0+ffZ0EtxzV2 eHk+GtVPxksbbceaM32PHoGkXxp8HaGOpI3dotFpQulThlcIdDKCf23pgn159RYTVWXr bLjg== X-Gm-Message-State: ACrzQf3PVA1mkv8lmKOqw8R06XLHm+Fz9UwLYMmagD3f3hkl/5mlOCPZ 5uup4YFkR7pg4UxcPDxL2YikeQ== X-Google-Smtp-Source: AMsMyM6jfwRi0igcgtP8NlX5XCTCI9iXBrg469ezzZODlwCSp+LE/lDHgH145M2jwzJFZG2F8RM4ZA== X-Received: by 2002:aa7:d348:0:b0:45b:8ae3:ee3d with SMTP id m8-20020aa7d348000000b0045b8ae3ee3dmr3440508edr.428.1666111214784; Tue, 18 Oct 2022 09:40:14 -0700 (PDT) Received: from google.com (64.227.90.34.bc.googleusercontent.com. [34.90.227.64]) by smtp.gmail.com with ESMTPSA id i18-20020a0564020f1200b00458a03203b1sm9244566eda.31.2022.10.18.09.40.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 09:40:14 -0700 (PDT) Date: Tue, 18 Oct 2022 16:40:11 +0000 From: Quentin Perret To: Will Deacon Cc: kvmarm@lists.linux.dev, Sean Christopherson , Vincent Donnefort , Alexandru Elisei , Catalin Marinas , James Morse , Chao Peng , Suzuki K Poulose , 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 v4 12/25] KVM: arm64: Add infrastructure to create and track pKVM instances at EL2 Message-ID: References: <20221017115209.2099-1-will@kernel.org> <20221017115209.2099-13-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221017115209.2099-13-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221018_094020_875463_D0E036D4 X-CRM114-Status: GOOD ( 12.28 ) 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 On Monday 17 Oct 2022 at 12:51:56 (+0100), Will Deacon wrote: > +static void *map_donated_memory_noclear(unsigned long host_va, size_t size) > +{ > + void *va = (void *)kern_hyp_va(host_va); > + > + if (!PAGE_ALIGNED(va)) > + return NULL; > + > + if (__pkvm_host_donate_hyp(hyp_virt_to_pfn(va), > + PAGE_ALIGN(size) >> PAGE_SHIFT)) > + return NULL; > + > + return va; > +} > + > +static void *map_donated_memory(unsigned long host_va, size_t size) > +{ > + void *va = map_donated_memory_noclear(host_va, size); > + > + if (va) > + memset(va, 0, size); > + > + return va; > +} > + > +static void __unmap_donated_memory(void *va, size_t size) > +{ > + WARN_ON(__pkvm_hyp_donate_host(hyp_virt_to_pfn(va), > + PAGE_ALIGN(size) >> PAGE_SHIFT)); > +} > + > +static void unmap_donated_memory(void *va, size_t size) > +{ > + if (!va) > + return; > + > + memset(va, 0, size); > + __unmap_donated_memory(va, size); > +} > + > +static void unmap_donated_memory_noclear(void *va, size_t size) > +{ > + if (!va) > + return; > + > + __unmap_donated_memory(va, size); > +} Nit: I'm not a huge fan of the naming here, these do more than just map/unmap random pages. This only works for host pages, the donation path has permission checks, etc. Maybe {admit,return}_host_memory()? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel