Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2128436yba; Mon, 15 Apr 2019 05:38:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwj0Dimt+7URlspp/JdLckOUWKI7o9JC7ZPgmBDPO1W6VszrLxwLdrPL5ZEpXWHdCjW9WYO X-Received: by 2002:a63:3f46:: with SMTP id m67mr54791981pga.178.1555331905752; Mon, 15 Apr 2019 05:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555331905; cv=none; d=google.com; s=arc-20160816; b=EOPEr/4MYqb5NnZ+N6uicuBfHwCPzSlSx4FcVhmd+xj1hSabRIL4ZlbHt2dw+Szhk2 lfJi+Iqx4HWGTWj8pqpseYbeeGGKcsUJakBhYQEKmv2HCZ9LHRXkDrfE1INlDUC2QGCu uG6a+PtX1cPOxdXsNSRpJN1HgSGmWQHKR98c9hhyGNoSvC7uML1G5oUDdCnu8gjc0lwG otOqI3AaemTIZvW0f40mW+7OJTcAXaPIuvyRV8CPL9XAdJ2f+u7AI7o4WGPkgiyfjztb FLK0AxfHk5LdN5tv6rlgYUsqLK32TMyzliyHOJTrUq/cCQjcj2yeDb/yRZkUiIapuGYf QYww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=MJ1TajX7uunmK7B+MEw6hlmA8kfBCz+33L5NNSIUd2g=; b=Bx9tzu1ZI+eH0Ww/4UJfvrJxEZcgYkxC0B/Q6VYcXEJPqZKeTJD4iEhybEgn5iqt4O 9ZwK26gfrjkPfw2isaqnv8xTLZAwZVZjfDUM/Pm1xXOFu/XMyMWWn4pT+ec1YLSuLEYo G6MhQF1tDBEyCfvGAicta58cnD7/LJfA+LohbppH4yxqurQPh1jhTnSdXXisb8VDl6vH wgKfhYIgTrIrhRnY+GQnrMA/713/15oBgQ5p++UJXSBvTaIvb0GPANnFWTFkYutCYcaX dhw7i6uHONiddhwByNE+j/+w7htrRuL0vHTb6iMFkEoMUv5B8ZaOT31rPJXLSardm0Ni WNVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hygon.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6si10599718plo.185.2019.04.15.05.38.09; Mon, 15 Apr 2019 05:38:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hygon.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727506AbfDOMhE (ORCPT + 99 others); Mon, 15 Apr 2019 08:37:04 -0400 Received: from [110.188.70.11] ([110.188.70.11]:13505 "EHLO spam2.hygon.cn" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727025AbfDOMhE (ORCPT ); Mon, 15 Apr 2019 08:37:04 -0400 Received: from spam2.hygon.cn (localhost [127.0.0.2] (may be forged)) by spam2.hygon.cn with ESMTP id x3FCAr4F059502; Mon, 15 Apr 2019 20:10:53 +0800 (GMT-8) (envelope-from fenghao@hygon.cn) Received: from MK-DB.hygon.cn ([172.23.18.60]) by spam2.hygon.cn with ESMTP id x3FC6aFG059155; Mon, 15 Apr 2019 20:06:36 +0800 (GMT-8) (envelope-from fenghao@hygon.cn) Received: from cncheex02.Hygon.cn ([172.23.18.12]) by MK-DB.hygon.cn with ESMTP id x3FC6RPv053895; Mon, 15 Apr 2019 20:06:27 +0800 (GMT-8) (envelope-from fenghao@hygon.cn) Received: from harry-Inspiron-5675.higon.com (172.23.18.44) by cncheex02.Hygon.cn (172.23.18.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1466.3; Mon, 15 Apr 2019 20:06:30 +0800 From: Hao Feng To: "'Tom Lendacky '" , "'Gary Hook '" , "'Herbert Xu '" , "' David S. Miller '" , "'Janakarajan Natarajan '" , "'Joerg Roedel '" , "'Paolo Bonzini '" , =?UTF-8?q?=27=20Radim=20Kr=C4=8Dm=C3=A1=C5=99=20=27?= , "'Thomas Gleixner '" , "'Ingo Molnar '" , "'Borislav Petkov '" , "' H. Peter Anvin '" CC: "'Zhaohui Du '" , "'Zhiwei Ying '" , "'Wen Pu '" , Hao Feng , , , , Subject: [PATCH 0/6] Add Hygon SEV support Date: Mon, 15 Apr 2019 20:04:22 +0800 Message-ID: <1555329868-17895-1-git-send-email-fenghao@hygon.cn> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.23.18.44] X-ClientProxiedBy: cncheex02.Hygon.cn (172.23.18.12) To cncheex02.Hygon.cn (172.23.18.12) X-MAIL: spam2.hygon.cn x3FC6aFG059155 X-DNSRBL: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hygon SEV follows AMD SEV work flow, but uses China national standard cryptographic algorithms SM2/SM3/SM4 instead of (RSA, ECDSA, ECDH)/SHA/AES. Reuse most AMD SEV code path to support Hygon SEV, also adds 3 new commands(GM_PUBKEY_GEN, GM_GET_DIGEST, GM_VERIFY_DIGEST) to support SM2 key exchange protocol. SM2 is based on ECC(Elliptic Curve Cryptography), and uses a special curve. It can be used in digital signature, key exchange and asymmetric cryptography. For key exchange, SM2 is similar to ECDH, but involves new random key, meaning the two sides need to exchange extra random public key besides their public key, that's why additional APIs are needed to support Hygon SEV. SM3 is a hash algorithm, similar to SHA-256. SM4 is a block cipher algorithm, similar to AES-128. 1. GM_PUBKEY_GEN ---------------- The command is used to get SM2 random public key from SEV firmware to compute share key. Parameters: * GM_KEY_ID_PADDR (in) - Address of key ID for the random public key. * GM_KEY_ID_LEN (in) - Length of key ID. * GM_PUBKEY_PADDR (in) - Address of the random public key. * GM_PUBKEY_LEN (in,out) - Length of the random public key. 2. GM_GET_DIGEST ---------------- The command is used to get key digest from SEV firmware during SM2 key exchange, guest owner can check the digest to see if the key negotiation is successful or not. Parameters: * HANDLE (in) - Guest handle * DIGEST_PADDR (in) - Address of the key digest * DIGEST_LEN (in, out) - Length of the key digest 3. GM_VERIFY_DIGEST ------------------- The command is used to send guest owner's key digest to SEV firmware during SM2 key exchange, firmware can check the digest to see if the negotiation is successful or not. Parameters: * HANDLE (in) - Guest handle * DIGEST_PADDR (in) - Address of the key digest * DIGEST_LEN (in) - Length of the key digest Already tested successfully on Hygon DhyanaPlus processor, also tested successfully on AMD EPYC processor, results show no side effect on current AMD SEV implementation. Hao Feng (6): crypto: ccp: Add Hygon Dhyana support crypto: ccp: Define Hygon SEV commands crypto: ccp: Implement SEV_GM_PUBKEY_GEN ioctl command KVM: Define Hygon SEV commands KVM: SVM: Add support for KVM_SEV_GM_GET_DIGEST command KVM: SVM: Add KVM_SEV_GM_VERIFY_DIGEST command arch/x86/kvm/svm.c | 119 +++++++++++++++++++++++++++++++++++++++++++ drivers/crypto/ccp/psp-dev.c | 86 +++++++++++++++++++++++++++++++ drivers/crypto/ccp/sp-pci.c | 2 + include/linux/psp-sev.h | 49 ++++++++++++++++++ include/uapi/linux/kvm.h | 14 +++++ include/uapi/linux/psp-sev.h | 17 +++++++ 6 files changed, 287 insertions(+) -- 2.7.4