Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3947184pxj; Mon, 21 Jun 2021 10:00:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzodWaUNx1Hou4bxigePQUcsAJ0Ah9lhb986FrevpEG9JM37XOIPfxH7/7OiBpCxGOJYEV X-Received: by 2002:a17:906:ca17:: with SMTP id jt23mr26162145ejb.334.1624294810905; Mon, 21 Jun 2021 10:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624294810; cv=none; d=google.com; s=arc-20160816; b=fYVrh1HJ41caDV1tkWkxnzFWsnEEjwijSSIP7bJWS3GeSvzAIY8PFHVmVhL41BVadF 1+QEXkSxMnR/ea1L/5gkcUlwghVqlXv+Bk71spcrDv/F5qrH+YPDa/btgu2yAONXoFje OUY7jtG00JlUL7XL+x/Wy20UhVBxHtoqQJFOjpMzE4NNF7O+CxGLmqMuAySaW/G2TIe9 f1U81v5HHeNrA6x5UntrMR/HWqgB0LCvl07q/eGdKZfX3FdDbgQw/SuhYIpwutx4FplE bUZIhDs8hEzmXG/QzUAEMsMuwOylEJcmkC+BIcCEqflmaw9ekJ3dD5pv/jAaIXGx6s8P zSJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=iiwJASZT/KKR/5QiXti53ciACJxa4B5DHzG+xVUiEiI=; b=ApcBrvZd19Qf6RfPNxmJCpHnPxXfb7w9W5xoe4fkX7ppfMK3eFiKJzYozij3epOknK Y8UbUV5aYti+6qahP1UAmnkqmx2uVNDgoqnmnx7zzLvJ2Efwsfhw9BpzA2QRK+Mqo4gl LlVuiJZEM51T9PWXG5LSmZzWFY4fX5wfNzVXUjlmzzyhKYS4Y/8wdS/RfI+2jTCQKOfQ 1PsbqEIlkW7VKzhMFfWukCtEoL+FSRi27YKCI8ExXAHHCppiHidxwdMYu/MGK34UcRK8 gAfmCzSb2o2OJZ+V/24AZjoCMXOaUU876kBF/7ROs2owCxby1twguuqvWfB6K7a8pMy2 74vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Ks/jlvia"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci12si11602438ejc.295.2021.06.21.09.59.48; Mon, 21 Jun 2021 10:00:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Ks/jlvia"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232679AbhFURBD (ORCPT + 99 others); Mon, 21 Jun 2021 13:01:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232381AbhFURAy (ORCPT ); Mon, 21 Jun 2021 13:00:54 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFC1CC0219B9 for ; Mon, 21 Jun 2021 09:31:29 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 4-20020a6315440000b029022154a87a57so12052184pgv.13 for ; Mon, 21 Jun 2021 09:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=iiwJASZT/KKR/5QiXti53ciACJxa4B5DHzG+xVUiEiI=; b=Ks/jlvia4+TwiFRGP23POzXrYebGUUn59ja4qfTmP7rwd0FvICRsgWSL50bvz7P5+r nbbsMlQwiKKN2/49ZluOdwF46nsc+hFm/wGsuL03SSMo3IiB5njZHjcECFk73ag5Ajag cj7Ss3ReZsHz/DT9/VFAsOrREenAweo1txxK3MzFQLtukQCUiCOQC6ThhI13qw64wpKE KA6sv2E5hWoeP01KdX4GaCAqwsjbIj8fhiycs0oFsU/41RXbWhvIye7flXg6i+WQBZeB MjDTDHjAW9P3WWtzOS2NJAoGjGrQv0AxIa3QGQre7AjVPXAoan5n8dNsG2JFEBDv/son WttA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=iiwJASZT/KKR/5QiXti53ciACJxa4B5DHzG+xVUiEiI=; b=JFhlQqoJVQvHzAKKaycdCcQgW/pf0q2R0xBvcjqXP27/eNZIkZIjejQYZAivxpbdRZ tApeBN98w5yAsLwppgOGHiOZpeitkTHdN05lks/WMfxuVGiRcPIJe8uH+gMiBovFqbQE BGsqgc0bdK4lmHPeeHtvXiTp8viYvqxPGlhpuFDbAFqXBAvmQhyNO3anfygvHE4L9Cw4 6rxjn+gBniZFur/zCOoH83ipR+YmXL05ck3H8VjjihQnqN/fljBf3YlLJfSVCVo3NSKh VVhcgRfgRClXV2dWr14xMR8fM3zVg/qH/DsM/SBxzA75Kgm3BWCOYBhwOpa6ohh6REfI 4fkQ== X-Gm-Message-State: AOAM533MLXaPxdyQ30LKnsvsrzMjKksSBMUIty1c611Mt/607zYreKhi njp6Cc/gEMIXbmb4DNioc5YxJonrN0s= X-Received: from pgonda1.kir.corp.google.com ([2620:0:1008:11:2742:338c:f077:6d85]) (user=pgonda job=sendgmr) by 2002:a17:90b:94c:: with SMTP id dw12mr8783727pjb.18.1624293089161; Mon, 21 Jun 2021 09:31:29 -0700 (PDT) Date: Mon, 21 Jun 2021 09:31:15 -0700 Message-Id: <20210621163118.1040170-1-pgonda@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog Subject: [PATCH 0/3] Add AMD SEV and SEV-ES local migration support From: Peter Gonda To: kvm@vger.kernel.org Cc: Peter Gonda , Paolo Bonzini , Sean Christopherson , David Rientjes , "Dr . David Alan Gilbert" , Brijesh Singh , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Local migration provides a low-cost mechanism for userspace VMM upgrades. It is an alternative to traditional (i.e., remote) live migration. Whereas remote migration handles move a guest to a new host, local migration only handles moving a guest to a new userspace VMM within a host. This can be used to update, rollback, change flags of the VMM, etc. The lower cost compared to live migration comes from the fact that the guest's memory does not need to be copied between processes. A handle to the guest memory simply gets passed to the new VMM, this could be done via using /dev/shm with share=on or similar feature. The guest state can be transferred from an old VMM to a new VMM as follows: 1. Export guest state from KVM to the old user-space VMM via a getter user-space/kernel API 2. Transfer guest state from old VMM to new VMM via IPC communication 3. Import guest state into KVM from the new user-space VMM via a setter user-space/kernel API VMMs by exporting from KVM using getters, sending that data to the new VMM, then setting it again in KVM. In the common case for local migration, we can rely on the normal ioctls for passing data from one VMM to the next. SEV, SEV-ES, and other confidential compute environments make most of this information opaque, and render KVM ioctls such as "KVM_GET_REGS" irrelevant. As a result, we need the ability to pass this opaque metadata from one VMM to the next. The easiest way to do this is to leave this data in the kernel, and transfer ownership of the metadata from one KVM VM (or vCPU) to the next. For example, we need to move the SEV enabled ASID, VMSAs, and GHCB metadata from one VMM to the next. In general, we need to be able to hand off any data that would be unsafe/impossible for the kernel to hand directly to userspace (and cannot be reproduced using data that can be handed safely to userspace). During the local send operation the SEV required metadata, the guest's ASID is loaded into a kvm wide hashmap keyed by a value given by userspace. This allows the userspace VMM to pass the key to the target VMM. Then on local receive the target VMM can be loaded with the metadata from the hashmap. Peter Gonda (3): KVM, SEV: Refactor out function for unregistering encrypted regions KVM, SEV: Add support for SEV local migration KVM, SEV: Add support for SEV-ES local migration .../virt/kvm/amd-memory-encryption.rst | 43 ++ arch/x86/kvm/svm/sev.c | 434 +++++++++++++++++- arch/x86/kvm/svm/svm.h | 1 + include/uapi/linux/kvm.h | 12 + 4 files changed, 471 insertions(+), 19 deletions(-) base-commit: f1b832550832 Cc: Paolo Bonzini Cc: Sean Christopherson Cc: David Rientjes Cc: Dr. David Alan Gilbert Cc: Brijesh Singh Cc: Vitaly Kuznetsov Cc: Wanpeng Li Cc: Jim Mattson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org -- 2.32.0.288.g62a8d224e6-goog