From patchwork Wed Nov 8 11:17:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 162976 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp843939vqo; Wed, 8 Nov 2023 03:24:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsl85hVADgUOSLHsh7SrqLrKOYFJIKEGOaV2Z2W/8f10h9wy1NWXfJZZC4VR9rtmtHY0RF X-Received: by 2002:a05:6a20:938a:b0:17d:faed:603c with SMTP id x10-20020a056a20938a00b0017dfaed603cmr2052318pzh.11.1699442651020; Wed, 08 Nov 2023 03:24:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699442651; cv=none; d=google.com; s=arc-20160816; b=Ye7zTd8R9UW21f52Z521dk5bChBaLGTJY3A0VJMUVcCa8YDn9g77EqNKeYBadiAqLo hllJkB5KgGTwvmxEynbxjavp4/mx3WlVkXezYh5iuH1iYRvc4shco0h39QyOABkmP4u8 un9iPpbNRQR97+Ll5XC6n5x9/ozAcqIFKVp/ymrE6N0BW7YeDqPpXVHzsuiJZFyRkjTG W/rTpgfLDSIh8FVFhGbfrvOEufF/eV7ZiWhaFUShhhd3vyJwKmB5FY+Ssv4mkgPSwjkI 9PYHa3fl1OcvI8LU/PBVd+xWpxA6V3N6c6f0Kd58cv3Om7DeDIa0DxY9yB2QRbfKk/xz 4dSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=76x6TGe5VGp4tVKNePmei2SbV9igg1iA9dnaIZiL/jY=; fh=Qdq7NqGm5JR9LpctBpXjoRI38Lb2mCk6xy26GEDp1Bg=; b=tZhKA5R4Y226XTVYsQ3Nzr6+gOsQm06seB8SYC50Xn5Cd8H6QpQHGTXRFTfzFuGPEj gJ9EyN6psJcgEnjBPFnOJeijB69EzSD9PTbKj7E7Vw37dmZIjnJp1NCPBRgJZB5hdiLp 4ZpNT0aoxYPZLQTI5dUQjYbwPgf4SPeWkE6SzTvVh0/hDPW9+sBOJrzkCrPkngmxwp0g aYN38cX3Qg8QHtEIn4TKc7ct95qV1DwWeB3qXiup7NuaKTQnh3CFV52gGZXzkwrY6fZz 44lWP8J8gdSJ/UgpI2OZZkCccVFtxICyMxL/czovr5EXFop9X/PPJxUpn182bRJfDjrt IuZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=i97E7MAB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id fe9-20020a056a002f0900b006c2d6a04897si11503907pfb.396.2023.11.08.03.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:24:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=i97E7MAB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 22BF183AC0EB; Wed, 8 Nov 2023 03:24:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344504AbjKHLYE (ORCPT + 32 others); Wed, 8 Nov 2023 06:24:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344827AbjKHLXm (ORCPT ); Wed, 8 Nov 2023 06:23:42 -0500 Received: from smtp-fw-52005.amazon.com (smtp-fw-52005.amazon.com [52.119.213.156]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE260212E; Wed, 8 Nov 2023 03:23:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1699442620; x=1730978620; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=76x6TGe5VGp4tVKNePmei2SbV9igg1iA9dnaIZiL/jY=; b=i97E7MABqSRQDtyaydCEB1rsc8IE0TjnNqrtGQB1JKMxakIFXmg9HS8g jyFUBdrAZWZXmYZxbYssDPmL4sN6rRYDGpd98gfbqQyLdKnF+9/vPEEoR TBOJVkPyqscHKzBCRwvqr6iUjrR3jar3V9/EfC3amdOV9VW2uN/irtgD3 U=; X-IronPort-AV: E=Sophos;i="6.03,286,1694736000"; d="scan'208";a="614866283" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2a-m6i4x-83883bdb.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-52005.iad7.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 11:23:37 +0000 Received: from smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev (pdx2-ws-svc-p26-lb5-vlan2.pdx.amazon.com [10.39.38.66]) by email-inbound-relay-pdx-2a-m6i4x-83883bdb.us-west-2.amazon.com (Postfix) with ESMTPS id 4CDD76098A; Wed, 8 Nov 2023 11:23:36 +0000 (UTC) Received: from EX19MTAEUB002.ant.amazon.com [10.0.43.254:38586] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.17.103:2525] with esmtp (Farcaster) id 9f4672c1-7f67-4ab2-9c06-a6e837041bd2; Wed, 8 Nov 2023 11:23:35 +0000 (UTC) X-Farcaster-Flow-ID: 9f4672c1-7f67-4ab2-9c06-a6e837041bd2 Received: from EX19D004EUC001.ant.amazon.com (10.252.51.190) by EX19MTAEUB002.ant.amazon.com (10.252.51.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Wed, 8 Nov 2023 11:23:35 +0000 Received: from dev-dsk-nsaenz-1b-189b39ae.eu-west-1.amazon.com (10.13.235.138) by EX19D004EUC001.ant.amazon.com (10.252.51.190) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Wed, 8 Nov 2023 11:23:30 +0000 From: Nicolas Saenz Julienne To: CC: , , , , , , , , , , , , , , , Nicolas Saenz Julienne Subject: [RFC 25/33] KVM: Introduce a set of new memory attributes Date: Wed, 8 Nov 2023 11:17:58 +0000 Message-ID: <20231108111806.92604-26-nsaenz@amazon.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231108111806.92604-1-nsaenz@amazon.com> References: <20231108111806.92604-1-nsaenz@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.13.235.138] X-ClientProxiedBy: EX19D035UWB001.ant.amazon.com (10.13.138.33) To EX19D004EUC001.ant.amazon.com (10.252.51.190) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 08 Nov 2023 03:24:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781994777176746332 X-GMAIL-MSGID: 1781994777176746332 Introduce the following memory attributes: - KVM_MEMORY_ATTRIBUTE_READ - KVM_MEMORY_ATTRIBUTE_WRITE - KVM_MEMORY_ATTRIBUTE_EXECUTE - KVM_MEMORY_ATTRIBUTE_NO_ACCESS Note that NO_ACCESS is necessary in order to make a distinction between the lack of attributes for a gfn, which defaults to the memory protections of the backing memory, versus explicitly prohibiting any access to that gfn. These new memory attributes will, for now, only made be available through the VSM KVM device (which we introduce in subsequent patches). Signed-off-by: Nicolas Saenz Julienne --- include/uapi/linux/kvm.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index bd97c9852142..6b875c1040eb 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -2314,7 +2314,11 @@ struct kvm_memory_attributes { __u64 flags; }; +#define KVM_MEMORY_ATTRIBUTE_READ (1ULL << 0) +#define KVM_MEMORY_ATTRIBUTE_WRITE (1ULL << 1) +#define KVM_MEMORY_ATTRIBUTE_EXECUTE (1ULL << 2) #define KVM_MEMORY_ATTRIBUTE_PRIVATE (1ULL << 3) +#define KVM_MEMORY_ATTRIBUTE_NO_ACCESS (1ULL << 4) #define KVM_CREATE_GUEST_MEMFD _IOWR(KVMIO, 0xd4, struct kvm_create_guest_memfd)