Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3586093pxk; Mon, 21 Sep 2020 18:53:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylihxdDMHJGyUb0ZHgQM+o4Z4CtC+mLTVXUHfU6m4qI8o1gzdCZnE2kkiJYv7WINIGNoSx X-Received: by 2002:a17:906:9591:: with SMTP id r17mr2516752ejx.424.1600739595539; Mon, 21 Sep 2020 18:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600739595; cv=none; d=google.com; s=arc-20160816; b=Ak0rj4Nlx3Z7rzkQrffPbYOhBzdKgQNO5ZgbF8E+VtoVPH1UsOP/g5a0bT+qUtGeKr sImECXdQ8rm3/vba0job/wG5WkCOVAQryTTTHKAn7lkn0DacOtMis5U26aFV/Xvm1QfL fGv6gdqchFElLd/XFJkIQLHrU5y5dc8aU1y/YRxjPY9iQdcDOPfOwspqXi2SF5nP4bLP OXOzxcOvoXQrmH84uhYeeZQ1GVOjt1YPH+8cVnZgwGwRuNc59/Cvs3D8duH4J/Q88VYv ArFGDO5yzot2VOTbFsfQOpr2ZtrpGKLMQsrSurZF2gjllUGjzeZKnnW2H2B+llPpCySi H1gA== 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:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=kaVjY3pUnRyNkcqQ+wVStnw4aNjDpVWSIpiyJwQk3hM=; b=yZHwGXvTbZJs71sOqcKhZqoYSR21vlYh0wa6dQuIk+FLDkCtk78wkKJW8uNo1ycAfD icRpv8ch7Ryf2bp3KvhIc5SeDyrw76/sljd/EcX2fDfCQOu8NotAof1KWFBVjbl6Eao4 B8A1nojz+ndgmwyoVPhbI/cw/DwiY0lapufUtHXSz+9Fbmq6gFEVOEvsquUrWcskp3R6 Ny6CEPY3r5PXJlJoAp2m0JTkyQdIsU3lHfUJiHHxB5Xg4dU+asPfZSLmUR52j7EeWG01 vvUjF3A3QYZOa7rb3o3UVtl4knWv7rFUxtNmACRQBar+PngWDqAMrixNS76dv8orpNl2 Uzug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=NzlEG3pM; 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 t6si8922974ejs.530.2020.09.21.18.52.52; Mon, 21 Sep 2020 18:53:15 -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=NzlEG3pM; 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 S1729349AbgIVAlA (ORCPT + 99 others); Mon, 21 Sep 2020 20:41:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729332AbgIVAk7 (ORCPT ); Mon, 21 Sep 2020 20:40:59 -0400 Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF78DC0613D0 for ; Mon, 21 Sep 2020 17:40:59 -0700 (PDT) Received: by mail-qv1-xf49.google.com with SMTP id f21so10546748qve.9 for ; Mon, 21 Sep 2020 17:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=kaVjY3pUnRyNkcqQ+wVStnw4aNjDpVWSIpiyJwQk3hM=; b=NzlEG3pMa4LAPyw5A4qMlN21mE2oVkOifW4wsp0GltmmOJdRWj73QzooJxEB84Aeh7 dwyd04/U+wB+LB+pHb2q2J6TsMz5x9WJM3GZw3qrcdILExfo1xSoRGLpskcjOjOMiYcH P405BPOdXAP8cd8kT1ihZkBOWSWKE33ZM7WtagvKbUuwNk4Mr6EDeyi8M6vuAEwGrbr8 Gk2Q266kF5ND2MP+GdfP/fwrNhKxaPgBU6Y4Tp2fI4Dt/MW4CS1aq6FnfZuBSJMVc5lG YyNz/thr7BtjOH8GCEu3gfy8iOI1WT9e7iUYiCk1fiIDlIofQnWlD+jKYadkPUisVbcs V/IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=kaVjY3pUnRyNkcqQ+wVStnw4aNjDpVWSIpiyJwQk3hM=; b=Yarse04W/YlBYZgNqXKk/Ap8fmd6tv7pizqTfj//FsUQjtzXWO7aO+Cq5MaoOUyKdt LhY/vpNMIp7xVGxRtgP3+rNh6mvw4h4gTad77lUZQg1Epnrujc+jENlsZiVwIGgvi8xv hbGj2EairTIKJkwZOYLEIKdQcJFJRQSCMHp+DFF3Q2xo2dp0eH7Y9WlV/k+znhLe4YXW 3ZFZzx4ijpjXuqNSiCrELz5SIqKAJUnoOw0oORqOHtGg+UqbD/dAlKDIFYoQRdJtt8ke Y8/r1M8lxb1h/xD6SlsqeCbvqtJVnd4U9UnMYjv0X2GFutrsEO/k6n+/1CLqY3nlpTiS nV+A== X-Gm-Message-State: AOAM533HSY9SYq5vLKhKcBJAFL/ICF1F8+NS/27plwkHB2/CRkghSA++ 1BQOWIH+3f+VrOySatmMqCxpqUImyTJD Sender: "vipinsh via sendgmr" X-Received: from vipinsh.kir.corp.google.com ([2620:0:1008:10:1ea0:b8ff:fe75:b885]) (user=vipinsh job=sendgmr) by 2002:a0c:e2c9:: with SMTP id t9mr3215691qvl.48.1600735258933; Mon, 21 Sep 2020 17:40:58 -0700 (PDT) Date: Mon, 21 Sep 2020 17:40:24 -0700 In-Reply-To: <20200922004024.3699923-1-vipinsh@google.com> Message-Id: <20200922004024.3699923-3-vipinsh@google.com> Mime-Version: 1.0 References: <20200922004024.3699923-1-vipinsh@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [RFC Patch 2/2] KVM: SVM: SEV cgroup controller documentation From: Vipin Sharma To: thomas.lendacky@amd.com, pbonzini@redhat.com, sean.j.christopherson@intel.com, tj@kernel.org, lizefan@huawei.com Cc: joro@8bytes.org, corbet@lwn.net, brijesh.singh@amd.com, jon.grimm@amd.com, eric.vantassell@amd.com, gingell@google.com, rientjes@google.com, kvm@vger.kernel.org, x86@kernel.org, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Vipin Sharma , Dionna Glaze , Erdem Aktas Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SEV cgroup controller documentation. Documentation for both cgroup versions, v1 and v2, of SEV cgroup controller. SEV controller is used to distribute and account SEV ASIDs usage by KVM on AMD processor. Signed-off-by: Vipin Sharma Reviewed-by: David Rientjes Reviewed-by: Dionna Glaze Reviewed-by: Erdem Aktas --- Documentation/admin-guide/cgroup-v1/sev.rst | 94 +++++++++++++++++++++ Documentation/admin-guide/cgroup-v2.rst | 56 +++++++++++- 2 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 Documentation/admin-guide/cgroup-v1/sev.rst diff --git a/Documentation/admin-guide/cgroup-v1/sev.rst b/Documentation/admin-guide/cgroup-v1/sev.rst new file mode 100644 index 000000000000..04d0024360a1 --- /dev/null +++ b/Documentation/admin-guide/cgroup-v1/sev.rst @@ -0,0 +1,94 @@ +============== +SEV Controller +============== + +Overview +======== + +The SEV controller regulates the distribution of SEV ASIDs. SEV ASIDs are used +in creating encrypted VMs on AMD processors. SEV ASIDs are stateful and one +ASID is only used in one KVM object at a time. It cannot be used with other KVM +before unbinding it from the previous KVM. + +All SEV ASIDs are tracked by this controller and it allows for accounting and +distribution of this resource. + +How to Enable Controller +======================== + +- Enable memory encryption on AMD platform:: + + CONFIG_KVM_AMD_SEV=y + +- Enable SEV controller:: + + CONFIG_CGROUP_SEV=y + +- Above options will build SEV controller support in the kernel. + To mount sev controller:: + + mount -t cgroup -o sev none /sys/fs/cgroup/sev + +Interface Files +============== + + sev.current + A read-only single value file which exists on non-root cgroups. + + The total number of SEV ASIDs currently in use by the cgroup and its + descendants. + + sev.max + A read-write single value file which exists on non-root cgroups. The + default is "max". + + SEV ASIDs usage hard limit. If the cgroup's current SEV ASIDs usage + reach this limit then the new SEV VMs creation will return error + -EBUSY. This limit cannot be set lower than sev.current. + + sev.events + A read-only flat-keyed single value file which exists on non-root + cgroups. A value change in this file generates a file modified event. + + max + The number of times the cgroup's SEV ASIDs usage was about to + go over the max limit. This is a tally of SEV VM creation + failures in the cgroup. + +Hierarchy +========= + +SEV controller supports hierarchical accounting. It supports following +features: + +1. SEV ASID usage in the cgroup includes itself and its descendent cgroups. +2. SEV ASID usage can never exceed the max limit set in the cgroup and its + ancestor's chain up to the root. +3. SEV events keep a tally of SEV VM creation failures in the cgroup and not in + its child subtree. + +Suppose the following example hierarchy:: + + root + / \ + A B + | + C + +1. A will show the count of SEV ASID used in A and C. +2. C's SEV ASID usage may not exceed any of the max limits set in C, A, or + root. +3. A's event file lists only SEV VM creation failed in A, and not the ones in + C. + +Migration and SEV ASID ownership +================================ + +An SEV ASID is charged to the cgroup which instantiated it, and stays charged +to that cgroup until that SEV ASID is freed. Migrating a process to a different +cgroup do not move the SEV ASID charge to the destination cgroup where the +process has moved. + +Deletion of a cgroup with existing ASIDs charges will migrate those ASIDs to +the parent cgroup. + diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst index 6be43781ec7f..66b8bdee8ff3 100644 --- a/Documentation/admin-guide/cgroup-v2.rst +++ b/Documentation/admin-guide/cgroup-v2.rst @@ -63,8 +63,11 @@ v1 is available under :ref:`Documentation/admin-guide/cgroup-v1/index.rst