From patchwork Wed Nov 8 11:18:01 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: 162988 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp847625vqo; Wed, 8 Nov 2023 03:31:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLDkb5ugy6RwKdZuOo7AjmygGfkuL8x/MXTQ7qNG5apkZhdfIwDEP2Avbp9jZto79l7vBj X-Received: by 2002:a05:6e02:1ca3:b0:359:4ae3:cd9a with SMTP id x3-20020a056e021ca300b003594ae3cd9amr1883264ill.30.1699443093534; Wed, 08 Nov 2023 03:31:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699443093; cv=none; d=google.com; s=arc-20160816; b=X1Lsb1zMREQRmxPZxLja5tJ5+ceGCHo/OemlDB8pAYcCx6XHGrUrNY0n/dFNFbwKWg Kk0/ctP26+JmrihUSM1uc8f7rU0V8vcW9R7IDwWqDo9DOmLt4cX7xHrpNztpx0vL+6/4 uktC9xpLQ/X0/25cm4KS6VjzilioYtdbQtuAcNQDa87zwo1ijt/fZyMDRZHD5wiJ09dP HwC0Kjku7owefUR7i/Xo9FhUP5PmTcLYYxOp0csISmBPoOQ8j8xaoC6HXGJhi42qOsfp nriy584nBAHnA2nZRqmKWTignMbgBo89j/F/S3Rk2FF4gPCvZhItxXfHnNINSZIBF6eh B28w== 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=wLo3D2RUMSrAbuSqouFk5tJc54p3vvp1g/yHmuVwsBM=; fh=Qdq7NqGm5JR9LpctBpXjoRI38Lb2mCk6xy26GEDp1Bg=; b=CVcycqPKRAgbI4Ktsot6V6qXmPdck/qquyj7euGSu2D3PWwNyBIVBN1zI4R7Uxma3M LdC2dwGYy+a69DCclbHFIH5dd6FUzmj+1w1tQjWbcfbNYGIrEjOVbmcuqSzrjW96C7st pbGrcAHa+t2pV6neHYqMfcZzVD2Z48U435SzhIiFWqr9YRWD+Z5H2/GyME0KnbCHye4Z hSlxDs2Q6VfR66Ib7jEErd9IN7yeaeWfqmH3wRc8FqSx4XO/XoOn2to1D1nyU+nX4Vo9 FRAgEYGkZo7X7K0ueH6V8/UcqXNQSWAyVn7bbXVlB9Lt7jbTXbHdnAMmMNL7ovVpeAsW Gu4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=NjJluvCs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id r73-20020a632b4c000000b005b99bfe3301si4596365pgr.462.2023.11.08.03.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 03:31:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=NjJluvCs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 0B02A8246844; Wed, 8 Nov 2023 03:31:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344193AbjKHLbR (ORCPT + 32 others); Wed, 8 Nov 2023 06:31:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235592AbjKHLbO (ORCPT ); Wed, 8 Nov 2023 06:31:14 -0500 Received: from smtp-fw-80009.amazon.com (smtp-fw-80009.amazon.com [99.78.197.220]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AB311BD5; Wed, 8 Nov 2023 03:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1699442663; x=1730978663; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wLo3D2RUMSrAbuSqouFk5tJc54p3vvp1g/yHmuVwsBM=; b=NjJluvCsCOrrryqvOqaerCThOkjj/PpkYw8LvGx1ve233rFh0+IfCpxW PoywF4AxUXWtszrYkNj8fgDp11qt5QGVFhaP+rxzf/7mmr29gIJb55apl 9ftHBAnSgUSRs7U+e9gUQRS9VRy/q9gseAHzWCywm08lTRdbl9HSp9/do s=; X-IronPort-AV: E=Sophos;i="6.03,286,1694736000"; d="scan'208";a="41962461" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1d-m6i4x-00fceed5.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80009.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Nov 2023 11:24:19 +0000 Received: from smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev (iad7-ws-svc-p70-lb3-vlan3.iad.amazon.com [10.32.235.38]) by email-inbound-relay-iad-1d-m6i4x-00fceed5.us-east-1.amazon.com (Postfix) with ESMTPS id 8D412A0DAB; Wed, 8 Nov 2023 11:24:15 +0000 (UTC) Received: from EX19MTAEUC002.ant.amazon.com [10.0.17.79:9042] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.26.101:2525] with esmtp (Farcaster) id ed9999cc-88dc-4223-ba6e-3219e585d98f; Wed, 8 Nov 2023 11:24:14 +0000 (UTC) X-Farcaster-Flow-ID: ed9999cc-88dc-4223-ba6e-3219e585d98f Received: from EX19D004EUC001.ant.amazon.com (10.252.51.190) by EX19MTAEUC002.ant.amazon.com (10.252.51.181) 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:24:14 +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:24:09 +0000 From: Nicolas Saenz Julienne To: CC: , , , , , , , , , , , , , , , Nicolas Saenz Julienne Subject: [RFC 28/33] x86/hyper-v: Introduce memory intercept message structure Date: Wed, 8 Nov 2023 11:18:01 +0000 Message-ID: <20231108111806.92604-29-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: EX19D031UWC003.ant.amazon.com (10.13.139.252) 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 (groat.vger.email [0.0.0.0]); Wed, 08 Nov 2023 03:31:31 -0800 (PST) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781995240690734251 X-GMAIL-MSGID: 1781995240690734251 Introduce struct hv_memory_intercept_message, which is used when issuing memory intercepts to a Hyper-V VSM guest. Signed-off-by: Nicolas Saenz Julienne --- arch/x86/include/asm/hyperv-tlfs.h | 76 ++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index af594aa65307..d3d74fde6da1 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -799,6 +799,82 @@ struct hv_get_vp_from_apic_id_in { u32 apic_ids[]; } __packed; + +/* struct hv_intercept_header::access_type_mask */ +#define HV_INTERCEPT_ACCESS_MASK_NONE 0 +#define HV_INTERCEPT_ACCESS_MASK_READ 1 +#define HV_INTERCEPT_ACCESS_MASK_WRITE 2 +#define HV_INTERCEPT_ACCESS_MASK_EXECUTE 4 + +/* struct hv_intercept_exception::cache_type */ +#define HV_X64_CACHE_TYPE_UNCACHED 0 +#define HV_X64_CACHE_TYPE_WRITECOMBINING 1 +#define HV_X64_CACHE_TYPE_WRITETHROUGH 4 +#define HV_X64_CACHE_TYPE_WRITEPROTECTED 5 +#define HV_X64_CACHE_TYPE_WRITEBACK 6 + +/* Intecept message header */ +struct hv_intercept_header { + __u32 vp_index; + __u8 instruction_length; +#define HV_INTERCEPT_ACCESS_READ 0 +#define HV_INTERCEPT_ACCESS_WRITE 1 +#define HV_INTERCEPT_ACCESS_EXECUTE 2 + __u8 access_type_mask; + union { + __u16 as_u16; + struct { + __u16 cpl:2; + __u16 cr0_pe:1; + __u16 cr0_am:1; + __u16 efer_lma:1; + __u16 debug_active:1; + __u16 interruption_pending:1; + __u16 reserved:9; + }; + } exec_state; + struct hv_x64_segment_register cs; + __u64 rip; + __u64 rflags; +} __packed; + +union hv_x64_memory_access_info { + __u8 as_u8; + struct { + __u8 gva_valid:1; + __u8 _reserved:7; + }; +}; + +struct hv_memory_intercept_message { + struct hv_intercept_header header; + __u32 cache_type; + __u8 instruction_byte_count; + union hv_x64_memory_access_info memory_access_info; + __u16 _reserved; + __u64 gva; + __u64 gpa; + __u8 instruction_bytes[16]; + struct hv_x64_segment_register ds; + struct hv_x64_segment_register ss; + __u64 rax; + __u64 rcx; + __u64 rdx; + __u64 rbx; + __u64 rsp; + __u64 rbp; + __u64 rsi; + __u64 rdi; + __u64 r8; + __u64 r9; + __u64 r10; + __u64 r11; + __u64 r12; + __u64 r13; + __u64 r14; + __u64 r15; +} __packed; + #include #endif