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=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 4BDCFC43460 for ; Tue, 6 Apr 2021 22:50:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A2D3613D8 for ; Tue, 6 Apr 2021 22:50:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344186AbhDFWuQ (ORCPT ); Tue, 6 Apr 2021 18:50:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344136AbhDFWuO (ORCPT ); Tue, 6 Apr 2021 18:50:14 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 324B3C06175F for ; Tue, 6 Apr 2021 15:50:06 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 131so22060511ybp.16 for ; Tue, 06 Apr 2021 15:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:message-id:mime-version:subject:from:to:cc; bh=29qkvQNMyHwLCHP8pXWRgWswaf/k2g0dTyIZhsX4Pvk=; b=mUCDW8goB/BkfT+GMgye4Lbl4vbr0CWjFY7SeZiXn3jP2soqTvTb9NToTJe9mZv29V 697bWQTz0SxGedUF1HwLD0JFxJvs20ZajAvN5qgCNhk+5Wkyc1TqJZjxJ4O+0Y2u+937 wy4sxbq50hDa62jBWPsHBBDxUDYKJapcfE2lO37hms0Sm0NsKUBuf+St+Gb5/f42Ezml eAe2CumEX7m0PTiQSq7OEXrbZ0w8TP2hSA9KfCv+DP0hI4IDeeFuVplbD7HFe4QuL2Y9 7l5yJmN9dl/lx9CQDk5TGNWLKUv3ZvNrHWqkDon/XSBNVfX4Lz4zdf5HoQgI2n3ZLhVr /9ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:message-id:mime-version:subject :from:to:cc; bh=29qkvQNMyHwLCHP8pXWRgWswaf/k2g0dTyIZhsX4Pvk=; b=I5bvkzmeu1ZTIT7n3f0mTweaYAdAcJR/wq44gM+/ijjBxRgDYfMww9OlJpfivJP6Zh hPIvdPhAZRD+y7/uScWIDj/i9sQ3rOXaWE/wlecRI25XSZeC6eBaq/dbdG3EjCdZ3L9n ARz/ikASDBGj1B11jPrSXEbN8pKSy8hKL1Y0vknWsIEAEZKD6byw1iK5c6aej5PHfqY1 QiQLCc6JO/4F3FRBIXBbfKvxstMF2Q3bkgnXMeAU/3c6b/qwzF2scGpq31j/cze2GZ6a UZnmxx7KnLxf7iRFIb2clL8Nji2beguT8xWblgfskFI3/uiH56ODSsJ19GNzwTC5HYVh JeyQ== X-Gm-Message-State: AOAM533+OBZ3mNsACFEAJO41Z7UZR6hw6He3n52VlEVWm1A6UM4CNtpy TuEKi31ASC9We7BjM2AkEUkXokpssys= X-Google-Smtp-Source: ABdhPJzRouXKIhQs8EfMqHUio8a2b3cN1QJZ0wcW2fPXd72cKuXtNJvbuk4wCZqugfRujJJGfODyK2fcLA0= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:24a1:90fb:182b:777c]) (user=seanjc job=sendgmr) by 2002:a25:2351:: with SMTP id j78mr536179ybj.102.1617749405370; Tue, 06 Apr 2021 15:50:05 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 6 Apr 2021 15:49:44 -0700 Message-Id: <20210406224952.4177376-1-seanjc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog Subject: [PATCH v2 0/8] ccp: KVM: SVM: Use stack for SEV command buffers From: Sean Christopherson To: Paolo Bonzini , Brijesh Singh , Tom Lendacky , John Allen Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Borislav Petkov , Christophe Leroy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series teaches __sev_do_cmd_locked() to gracefully handle vmalloc'd command buffers by copying _all_ incoming data pointers to an internal buffer before sending the command to the PSP. The SEV driver and KVM are then converted to use the stack for all command buffers. Tested everything except sev_ioctl_do_pek_import(), I don't know anywhere near enough about the PSP to give it the right input. v2: - Rebase to kvm/queue, commit f96be2deac9b ("KVM: x86: Support KVM VMs sharing SEV context"). - Unconditionally copy @data to the internal buffer. [Christophe, Brijesh] - Allocate a full page for the buffer. [Brijesh] - Drop one set of the "!"s. [Christophe] - Use virt_addr_valid() instead of is_vmalloc_addr() for the temporary patch (definitely feel free to drop the patch if it's not worth backporting). [Christophe] - s/intput/input/. [Tom] - Add a patch to free "sev" if init fails. This is not strictly necessary (I think; I suck horribly when it comes to the driver framework). But it felt wrong to not free cmd_buf on failure, and even more wrong to free cmd_buf but not sev. v1: - https://lkml.kernel.org/r/20210402233702.3291792-1-seanjc@google.com Sean Christopherson (8): crypto: ccp: Free SEV device if SEV init fails crypto: ccp: Detect and reject "invalid" addresses destined for PSP crypto: ccp: Reject SEV commands with mismatching command buffer crypto: ccp: Play nice with vmalloc'd memory for SEV command structs crypto: ccp: Use the stack for small SEV command buffers crypto: ccp: Use the stack and common buffer for status commands crypto: ccp: Use the stack and common buffer for INIT command KVM: SVM: Allocate SEV command structures on local stack arch/x86/kvm/svm/sev.c | 262 +++++++++++++---------------------- drivers/crypto/ccp/sev-dev.c | 197 +++++++++++++------------- drivers/crypto/ccp/sev-dev.h | 4 +- 3 files changed, 196 insertions(+), 267 deletions(-) -- 2.31.0.208.g409f899ff0-goog