From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9280222593 for ; Thu, 19 Dec 2024 11:10:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734606630; cv=none; b=R6aSypyuL9U/Qgul8Txfkj5dHSwNIPGTLWfNUsda6qIVGCvkCcgV8GPANtGfF9+sLeP6K5DtsEnAlQQUcnH6dSkKuXKtiBlnQLJVCU9hi1vKbKMdRWlD+xEiFXZh2ji0HqoSdzgl2XumN4rZVAjgbVDY91ZmN+nnPpgp2bIO/CE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734606630; c=relaxed/simple; bh=KA1ixWNP5WI3RizWmsymPfBhlXudCJCqwF4L4GJqyeo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nmYIaTUze+UlU+zdyr0UrCyM2jR9+iaxzuADnTKu1aYy5VjhVReOTgO7Uiofi8nMtbMiX572B50+EJQtABYiJSyK/ZOmZR/JVNNqa0nWg1NQjJiWsJOSBEkeleofGekJYL+0X3diMfN/9y5atvkJMs0aPfKPJ3qwfMz8pE5yRec= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4Sa80QI4; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4Sa80QI4" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-aa689a37dd4so131485966b.3 for ; Thu, 19 Dec 2024 03:10:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734606627; x=1735211427; darn=vger.kernel.org; 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=d5b9H3Sr5EYFy0j2cHR9n5SDx5jRbjOaoGMUJe0iL/U=; b=4Sa80QI4fghf+r3Qyhf4VIXFh5BvOSVIpktUVsDadazmImpt7hDmkDRdVfl+L+SnQt 8ZtmEsznqs13jzrYUs7tSnoG3zaKk1bBhWLSlpitrSE1wU2fBO5lPm/yzhKN9pIyEr2O uZuNv+EtpV8FeLHhICJH6MbiF5WJf13whVeV8mG24ITzF+YYhgL3kmsRQtUNsTuXnx2l keXD2iJsKS1AEwTIzbeToMlpkSriST+NKONhmhI7llMJbHTh2wBhlBYR7fEDUNnGO1UL EXgduR3v7s4OGp1wll9LP73JjYyj48Q1KMGlSphU9UZgab7rEjhuswYByOqxYXk8/zNh gDTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734606627; x=1735211427; 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=d5b9H3Sr5EYFy0j2cHR9n5SDx5jRbjOaoGMUJe0iL/U=; b=ZCrtgzaTn+o9forlMha3CReCpbo2nFY8M5y4Mdg7ZuVkf2Fad+rgkVJ0Gl6ODAii2B rKKCOzQD5W+kiobsLH7S2D3VagtOJsqhSRGtOcacWLy5PloGwmYgS1/RFNtHOR2KdFbO rAQBlhKlD/bhg+fT8ae1pNGBO28XElGTYfTvE1fqZoV3tjJQGhgLpum1QuZQkGGPbz/4 FIU22JbdOanKkjEzQXNJPjmNKhSUVbU3VB22LudPv4/NIOXV7SJyS9By8IDiHjmdOIUm i4aCAtxdwYndGALobk19RUV0seHegBDvcLMadLdEhSWVW+E6tNogVekwFbB4tvoA8Ii8 uAXA== X-Forwarded-Encrypted: i=1; AJvYcCUpQqUR8StqGBjBcELyTCqp8RHfHStxS3EPKxxepJXL46WRWUm+PyYs84ryxa/bSDvV7F+GleY4apDVQOo=@vger.kernel.org X-Gm-Message-State: AOJu0YzH1Tda95TSwcMcJL9FKmgurmvvqfvmJTbweQeoo0aDQfFMOtky HYMnZC2QoR6XnXdPwq3CexeV0QFRU2hU0yN+pv8SljzhISfW5IEke8e72moGmA== X-Gm-Gg: ASbGncuUpYsttnbL7PtypiC7MkEpi7q6Qm5xsGz8Jba6aTL+V3sL0w9to0yvDh2hEIZ GqEAiNAe7ffhzozwihYi7ae3zMik0l4hn59h/vgI//l4CLrRCGNFW9j94VbhxCtzv/6158G9Cz9 tksYCD6G4K6jTUdm5J/D+ro134g47o8j4QQZtg0+HeBYoXEpUj9W1uVQZru0mvC8dbfOSvEGLBd ghoEGUdRmhOYB0+3UIjGpYYoTFhsyxQKPR4rRn6AI024Kl6BcTFFz81Zy/gaOD/poYbyZLpyALY 7BGqnu90O+6vfjs= X-Google-Smtp-Source: AGHT+IG1QUopT3Ag0ASkVgubCSavXZGnEyoaVH9YZtChHHKZ/cqx6LkSAMoHjTC7eHCXPYeU1uUf5Q== X-Received: by 2002:a17:907:7da0:b0:aa6:8d51:8fdb with SMTP id a640c23a62f3a-aac079029cdmr282978566b.19.1734606626623; Thu, 19 Dec 2024 03:10:26 -0800 (PST) Received: from google.com (61.134.90.34.bc.googleusercontent.com. [34.90.134.61]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aac0e894f7fsm54124966b.46.2024.12.19.03.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2024 03:10:26 -0800 (PST) Date: Thu, 19 Dec 2024 11:10:23 +0000 From: Quentin Perret To: Mostafa Saleh Cc: iommu@lists.linux.dev, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, robdclark@gmail.com, joro@8bytes.org, robin.murphy@arm.com, jean-philippe@linaro.org, jgg@ziepe.ca, nicolinc@nvidia.com, vdonnefort@google.com, tabba@google.com, danielmentz@google.com, tzukui@google.com Subject: Re: [RFC PATCH v2 21/58] KVM: arm64: pkvm: Add __pkvm_host_add_remove_page() Message-ID: References: <20241212180423.1578358-1-smostafa@google.com> <20241212180423.1578358-22-smostafa@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241212180423.1578358-22-smostafa@google.com> On Thursday 12 Dec 2024 at 18:03:45 (+0000), Mostafa Saleh wrote: > From: Jean-Philippe Brucker > +/* > + * Temporarily unmap a page from the host stage-2, if @remove is true, or put it > + * back. After restoring the ownership to host, the page will be lazy-mapped. > + */ > +int __pkvm_host_add_remove_page(u64 pfn, bool remove) > +{ > + int ret; > + u64 host_addr = hyp_pfn_to_phys(pfn); > + u8 owner = remove ? PKVM_ID_HYP : PKVM_ID_HOST; > + > + host_lock_component(); > + ret = host_stage2_set_owner_locked(host_addr, PAGE_SIZE, owner); Any reason why this can't be expressed using __pkvm_host_donate_hyp() and __pkvm_hyp_donate_host()? This doesn't check any state, so it feels like a dangerous primitive to have. Is the issue the overhead of mapping/unmapping into EL2 stage-1?