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 038ABCED25B for ; Tue, 8 Oct 2024 02:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KM6xf6sEqcjRtyhQgAbYMNmNaySSsAseblPrEZ4b2lY=; b=3FSCoca+s1srhWJ4pxlP5pmIhp O8kEOE+4JKlLYJ08MX1BT5O0QfMV3vSN7ihNMnWtBFpnkbm5PcVVgLc6QhoDrAmSKkS/5ZOn+Kf2+ B7yuWzJYnQzg/9E28bOfaB+FQWf1WVECqofi3I7vzXtdWaaFarQT8f9Il8LzY9lV09ldaOG4Yb7Yx pD0rWqJWvevKu9WfYX+iPNX2ukqZR93s6T7GMYUI7dT2UqbBUH5CgYATM4TK0F+0HyurCSxzyLnKs 0+M60pQf2WCnyrsyebkbXqJvZqeEL6ICbxLNy75ehKN7+CYV/W2OSI8tzpR6gm+UMRt8lrLe5OMec jaYfFW7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sy0QR-00000004LQg-1xRS; Tue, 08 Oct 2024 02:58:15 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sy0P8-00000004LFZ-0HSe for linux-arm-kernel@lists.infradead.org; Tue, 08 Oct 2024 02:56:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728356212; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KM6xf6sEqcjRtyhQgAbYMNmNaySSsAseblPrEZ4b2lY=; b=StanVK6VaB39Xdiw/TbzBUGxwApbw7JV6TgOwKcjptNPJRRQXpSgAvs1Al3agKq1NlmZQF KQjSXrX3BBN4FmPxVbQsuSwifUIgm9urNwuxPps5pUbxMhUeNeHppzxcpJS98MTKpZvrPc 06fa0NgXT0D+BHLgK8tDcaLRO/bPKok= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-480-Qb5PSiWUOFaa663QeZ5O5w-1; Mon, 07 Oct 2024 22:56:46 -0400 X-MC-Unique: Qb5PSiWUOFaa663QeZ5O5w-1 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-2e2859da7c2so191555a91.2 for ; Mon, 07 Oct 2024 19:56:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728356205; x=1728961005; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KM6xf6sEqcjRtyhQgAbYMNmNaySSsAseblPrEZ4b2lY=; b=pV5TKfty5jZ0LhWt8tXKpDm1qMZoOXzEK5Srtv9I5QnpbHjrIXjAGiSCpOMMQHRsLf N+DfZu0WbARYhkGM1mqf5n7sPej7GIVtEbRn0PgbV+WZToPEHUf8nfXo5zvOB7BLdDcB Lrq/uPziXSVCVpt/8jRRFGZGCQFKArnBlxr0GF66gGMPsyansGwW9unXKny7lVJaB/X3 6uTW6DFaIuj9cX8KiEFBmThIblnwWphKVtE/Wpx1GjU3eejpOnAo46MKXL/8EuLq7PE+ 3slJwh/VcLKyYkheZqLgTPFg0LVaSERq93RhkQWiFlbdmNQf0895qrrYDooQfd7o7tl1 Yf1Q== X-Forwarded-Encrypted: i=1; AJvYcCV+YNaj4kVL9a8WfQEEVxpLl9qO9Er7u0Wt6Se5MIBxrXapqiqJKz2TxSn+3CvNC7pXPAlmGb9Jflk4nEDjULf5@lists.infradead.org X-Gm-Message-State: AOJu0YwkgWrhAlD8BtzWS4cWwjQz/7BGkHzhpn87Wl/R9e+3G5WhQnu5 DRpnXU5qNhX04ocK5wXnqq/6fktTPf4GWs/0HHfuXdqikuis8gFellGoQZVGlsTOmrATRZPthsR 94A3FKSRHt8vjP+RWG1Hf/gsw0Joxn6ZDA2Uj7nmjQxgC4rGkABp5RThnPblLPLUXAtSXNOlF X-Received: by 2002:a17:90b:3c87:b0:2da:905a:d893 with SMTP id 98e67ed59e1d1-2e1e636c83dmr16775542a91.31.1728356205266; Mon, 07 Oct 2024 19:56:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0LUzICRMByd9uxAUa++9+87v1zVZqbecdEx3xdGyOmYX5ElCHosgfateZaUDyS8uZx+7XTA== X-Received: by 2002:a17:90b:3c87:b0:2da:905a:d893 with SMTP id 98e67ed59e1d1-2e1e636c83dmr16775512a91.31.1728356204947; Mon, 07 Oct 2024 19:56:44 -0700 (PDT) Received: from [192.168.68.54] ([103.210.27.132]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e1e85da3f0sm7939061a91.30.2024.10.07.19.56.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Oct 2024 19:56:44 -0700 (PDT) Message-ID: <6fda5d7d-4214-460c-a727-9bb3382aa78f@redhat.com> Date: Tue, 8 Oct 2024 12:56:36 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 09/11] arm64: Enable memory encrypt for Realms To: Steven Price , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Suzuki K Poulose , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" References: <20241004144307.66199-1-steven.price@arm.com> <20241004144307.66199-10-steven.price@arm.com> From: Gavin Shan In-Reply-To: <20241004144307.66199-10-steven.price@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241007_195654_216116_B7499126 X-CRM114-Status: GOOD ( 17.39 ) 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 On 10/5/24 12:43 AM, Steven Price wrote: > From: Suzuki K Poulose > > Use the memory encryption APIs to trigger a RSI call to request a > transition between protected memory and shared memory (or vice versa) > and updating the kernel's linear map of modified pages to flip the top > bit of the IPA. This requires that block mappings are not used in the > direct map for realm guests. > > Signed-off-by: Suzuki K Poulose > Co-developed-by: Steven Price > Signed-off-by: Steven Price > Reviewed-by: Catalin Marinas > --- > Changes since v5: > * Added comments and a WARN() in realm_set_memory_{en,de}crypted() to > explain that memory is leaked if the transition fails. This means the > callers no longer need to provide their own WARN. > Changed since v4: > * Reworked to use the new dispatcher for the mem_encrypt API > Changes since v3: > * Provide pgprot_{de,en}crypted() macros > * Rename __set_memory_encrypted() to __set_memory_enc_dec() since it > both encrypts and decrypts. > Changes since v2: > * Fix location of set_memory_{en,de}crypted() and export them. > * Break-before-make when changing the top bit of the IPA for > transitioning to/from shared. > --- > arch/arm64/Kconfig | 3 + > arch/arm64/include/asm/mem_encrypt.h | 9 +++ > arch/arm64/include/asm/pgtable.h | 5 ++ > arch/arm64/include/asm/set_memory.h | 3 + > arch/arm64/kernel/rsi.c | 16 +++++ > arch/arm64/mm/pageattr.c | 90 +++++++++++++++++++++++++++- > 6 files changed, 123 insertions(+), 3 deletions(-) > Reviewed-by: Gavin Shan