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 X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8211C433DB for ; Sun, 28 Feb 2021 15:04:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3C91064ECE for ; Sun, 28 Feb 2021 15:04:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C91064ECE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 92D708D0022; Sun, 28 Feb 2021 10:04:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8DF818D0019; Sun, 28 Feb 2021 10:04:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F5218D0022; Sun, 28 Feb 2021 10:04:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id 69DD48D0019 for ; Sun, 28 Feb 2021 10:04:13 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 26E6383FD for ; Sun, 28 Feb 2021 15:04:13 +0000 (UTC) X-FDA: 77867997186.14.AD26807 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf01.hostedemail.com (Postfix) with ESMTP id F3A28200026F for ; Sun, 28 Feb 2021 15:04:11 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id u12so9436935pjr.2 for ; Sun, 28 Feb 2021 07:04:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dvx8sVFIDRwA8HVv8xs6M9vOFGJJY4qZU9vG5iVcN/Y=; b=YsLAgDSNMyIOu25iL5HDcBHtEXYrJHnLmdyiqj1AARPg/PfsaJRNxva/ZmUaVRdoHv rLkWgBcdz1Yrs/KlgNnltALdC4XAmlJUO2eW3dZuSTOvJgoo7TutGtB7KMtcvhKlkk4D YAi7rWCAedue4X5LMIe/VeMgG1eKG5toeZARu1a6Cov0xPzJlSFtI+7JlZGwqxWjk7UO /9Y4RXC1tJZQ6aH44tBe4XGScQbMLQJyWuVd15aQ58fCSXCqGm0XH4w79CcNAG2EJkJV SQpQK5Z9SyaL1SCQOI78U01EW4Q3Myc/0sx6HjYIAR12WdeSidWSmehInifKRV7ROz4p u3Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dvx8sVFIDRwA8HVv8xs6M9vOFGJJY4qZU9vG5iVcN/Y=; b=gjN+HUNVxBJyBN1tmBu9ql9F+mZwewyHdeck2SWdSRjLijONYYkHJo7AWlVpEzpHEr ZASVhxjsfxeJmtrBynlW3MXkTkX98coMGjunTpMoD6nuM08t7aiXEUZlAKw9gK89WDFN lJehzTTU0Fb1QPSv4DHAHuSgvpnsV+B7U/UXB6b0QH/1i8BpuJ7AlEjuaqobVCPPx3yg 4sUOCSKmzAVFMnRSNO27uTXvGE/gOrqc8SBx6bKJcGqFaMuS+Z+PQeAWCYwUrsVuyQcZ o66J91uvAMJpKHCo0T8Ep4e7pqZXaTpvqwDGVGVBrJMUN4Sm5PgbjqruMEEHeuj8PecV wrXQ== X-Gm-Message-State: AOAM530Gfn+anNq6IDTNXpP1M7VbU/SP9RWDD+QoJ7ZQVak/8DE9eXQi 28+SaNjHn4if2rZl4S131bg= X-Google-Smtp-Source: ABdhPJx9/Zp+U49TtzTJQxCqHd5e6WrN5zxO4e73fPvqhTp4oeAJQVgJ5GrOQDMc7rVs1BQ0aBf5RA== X-Received: by 2002:a17:90a:8a8b:: with SMTP id x11mr11255886pjn.151.1614524651791; Sun, 28 Feb 2021 07:04:11 -0800 (PST) Received: from ubuntu-Virtual-Machine.corp.microsoft.com ([2001:4898:80e8:0:561f:afde:af07:8820]) by smtp.gmail.com with ESMTPSA id 142sm8391331pfz.196.2021.02.28.07.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Feb 2021 07:04:11 -0800 (PST) From: Tianyu Lan To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, davem@davemloft.net, kuba@kernel.org, gregkh@linuxfoundation.org, arnd@arndb.de, akpm@linux-foundation.org, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: Tianyu Lan , linux-arch@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-scsi@vger.kernel.org, netdev@vger.kernel.org, vkuznets@redhat.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, sunilmut@microsoft.com Subject: [RFC PATCH 00/12] x86/Hyper-V: Add Hyper-V Isolation VM support Date: Sun, 28 Feb 2021 10:03:03 -0500 Message-Id: <20210228150315.2552437-1-ltykernel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: F3A28200026F X-Stat-Signature: a7u9brderf6fyn6afutisbthyyxqepcy Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mail-pj1-f51.google.com; client-ip=209.85.216.51 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614524651-696955 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Tianyu Lan Hyper-V provides two kinds of Isolation VMs. VBS(Virtualization-based security) and AMD SEV-SNP unenlightened Isolation VMs. This patchset is to add support for these Isolation VM support in Linux. The memory of these vms are encrypted and host can't access guest memory directly. Hyper-V provides new host visibility hvcall and the guest needs to call new hvcall to mark memory visible to host before sharing memory with host. For security, all network/storage stack memory should not be shared with host and so there is bounce buffer requests. Vmbus channel ring buffer already plays bounce buffer role because all data from/to host needs to copy from/to between the ring buffer and IO stack memory. So mark vmbus channel ring buffer visible. There are two exceptions - packets sent by vmbus_sendpacket_ pagebuffer() and vmbus_sendpacket_mpb_desc(). These packets contains IO stack memory address and host will access these memory. So add allocation bounce buffer support in vmbus for these packets. For SNP isolation VM, guest needs to access the shared memory via extra address space which is specified by Hyper-V CPUID HYPERV_CPUID_ ISOLATION_CONFIG. The access physical address of the shared memory should be bounce buffer memory GPA plus with shared_gpa_boundary reported by CPUID. Tianyu Lan (12): x86/Hyper-V: Add visibility parameter for vmbus_establish_gpadl() x86/Hyper-V: Add new hvcall guest address host visibility support x86/HV: Initialize GHCB page and shared memory boundary HV: Add Write/Read MSR registers via ghcb HV: Add ghcb hvcall support for SNP VM HV/Vmbus: Add SNP support for VMbus channel initiate message hv/vmbus: Initialize VMbus ring buffer for Isolation VM x86/Hyper-V: Initialize bounce buffer page cache and list x86/Hyper-V: Add new parameter for vmbus_sendpacket_pagebuffer()/mpb_desc() HV: Add bounce buffer support for Isolation VM HV/Netvsc: Add Isolation VM support for netvsc driver HV/Storvsc: Add bounce buffer support for Storvsc arch/x86/hyperv/Makefile | 2 +- arch/x86/hyperv/hv_init.c | 70 +++- arch/x86/hyperv/ivm.c | 257 ++++++++++++ arch/x86/include/asm/hyperv-tlfs.h | 22 + arch/x86/include/asm/mshyperv.h | 26 +- arch/x86/kernel/cpu/mshyperv.c | 2 + drivers/hv/Makefile | 2 +- drivers/hv/channel.c | 103 ++++- drivers/hv/channel_mgmt.c | 30 +- drivers/hv/connection.c | 68 +++- drivers/hv/hv.c | 196 ++++++--- drivers/hv/hv_bounce.c | 619 +++++++++++++++++++++++++++++ drivers/hv/hyperv_vmbus.h | 42 ++ drivers/hv/ring_buffer.c | 83 +++- drivers/net/hyperv/hyperv_net.h | 5 + drivers/net/hyperv/netvsc.c | 111 +++++- drivers/scsi/storvsc_drv.c | 46 ++- drivers/uio/uio_hv_generic.c | 13 +- include/asm-generic/hyperv-tlfs.h | 1 + include/asm-generic/mshyperv.h | 24 +- include/linux/hyperv.h | 46 ++- mm/ioremap.c | 1 + mm/vmalloc.c | 1 + 23 files changed, 1614 insertions(+), 156 deletions(-) create mode 100644 arch/x86/hyperv/ivm.c create mode 100644 drivers/hv/hv_bounce.c --=20 2.25.1