Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp426627ybg; Thu, 19 Mar 2020 02:17:45 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsY+wXugxgoE9hC3ATeLDWDvy2pqY8udtq7hv1QElfMYWCAyqG5/DRJSD5Og6oehcqNzd5b X-Received: by 2002:aca:c552:: with SMTP id v79mr1558487oif.156.1584609465413; Thu, 19 Mar 2020 02:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584609465; cv=none; d=google.com; s=arc-20160816; b=qF4jKutv75uYG7BYXMV3VimdhbN2ACP1/+aCmvt11PKV4M5H8N+NEcspTHHn6LvtOA sHYJr1yuJky3q/x0BXL2/aVNABe/YfcjaioOWdlxfGMvmQz+26jwNLEZaZ85U4IMIxeO bhzUyvuR2jr7hmY/WvTk3pwWVoITIWby11JrUNtTu+IgyLS/3ObYG70yrY7Uf4dLgg76 rZmTzfO3Pm2EHgPkPdlxUt7slZ6U26+/XjnYtEysqQZl7JbaYRj2I8hMqw6gUvNRWG4o hG3+x/8uF4/HGLPxvSCemPUQ1I87L8bPTKjEf4MOwBpk37FyXrq0WmKPeKwLNiapOr9J Y0rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=kLEKt61kQ9aFHmtuW5oUb+Q5DW4X7b9UgXVtY1K2IGY=; b=NU8Zfy5Hh+wLgUIfatbqWhmDa/vo8SMDRqjhHVgDYwKpH0siFVXHLn9jVDpq/qL19X abuUpsP1ynt0i4A//C3VtLv1DVWXQr3OkAL/tgGoSb7OCn9tpYiiOIAm6jWCCk7beNKP 1I9pE1bPdVKNvu5er7zgcTqBnmsDDYXuDAdo/MPzONwO2inyFLeCO5YN5dtDFZ8451fY kt7ZVIqyJmzXvu3nPoJwKgARYs/rW90Fw4MifC6DggJvZJ5WyckPByFZia2HDzzESBHs GjXP+wWSqwvRdIrMrEsT76wDvGc0IgOIJHtCshOkz8ry7IflMGWhzy/uUt/Yq8T8QwEh fEEw== 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=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si958242otr.237.2020.03.19.02.17.32; Thu, 19 Mar 2020 02:17:45 -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=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727745AbgCSJQa (ORCPT + 99 others); Thu, 19 Mar 2020 05:16:30 -0400 Received: from 8bytes.org ([81.169.241.247]:51922 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727460AbgCSJOo (ORCPT ); Thu, 19 Mar 2020 05:14:44 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 95E19E97; Thu, 19 Mar 2020 10:14:26 +0100 (CET) From: Joerg Roedel To: x86@kernel.org Cc: hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Thomas Hellstrom , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, Joerg Roedel , Joerg Roedel Subject: [PATCH 55/70] x86/sev-es: Handle RDTSCP Events Date: Thu, 19 Mar 2020 10:13:52 +0100 Message-Id: <20200319091407.1481-56-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200319091407.1481-1-joro@8bytes.org> References: <20200319091407.1481-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Extend the RDTSC handler to also handle RDTSCP events. Signed-off-by: Joerg Roedel --- arch/x86/kernel/sev-es.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/sev-es.c b/arch/x86/kernel/sev-es.c index a4f136b2e149..11947b648b43 100644 --- a/arch/x86/kernel/sev-es.c +++ b/arch/x86/kernel/sev-es.c @@ -665,19 +665,25 @@ static enum es_result vc_handle_wbinvd(struct ghcb *ghcb, return sev_es_ghcb_hv_call(ghcb, ctxt, SVM_EXIT_WBINVD, 0, 0); } -static enum es_result vc_handle_rdtsc(struct ghcb *ghcb, struct es_em_ctxt *ctxt) +static enum es_result vc_handle_rdtsc(struct ghcb *ghcb, + struct es_em_ctxt *ctxt, + unsigned long exit_code) { + bool rdtscp = (exit_code == SVM_EXIT_RDTSCP); enum es_result ret; - ret = sev_es_ghcb_hv_call(ghcb, ctxt, SVM_EXIT_RDTSC, 0, 0); + ret = sev_es_ghcb_hv_call(ghcb, ctxt, exit_code, 0, 0); if (ret != ES_OK) return ret; - if (!(ghcb_is_valid_rax(ghcb) && ghcb_is_valid_rdx(ghcb))) + if (!(ghcb_is_valid_rax(ghcb) && ghcb_is_valid_rdx(ghcb) && + (!rdtscp || ghcb_is_valid_rcx(ghcb)))) return ES_VMM_ERROR; ctxt->regs->ax = ghcb->save.rax; ctxt->regs->dx = ghcb->save.rdx; + if (rdtscp) + ctxt->regs->cx = ghcb->save.rcx; return ES_OK; } @@ -716,7 +722,8 @@ static enum es_result vc_handle_exitcode(struct es_em_ctxt *ctxt, result = vc_handle_dr7_write(ghcb, ctxt, early); break; case SVM_EXIT_RDTSC: - result = vc_handle_rdtsc(ghcb, ctxt); + case SVM_EXIT_RDTSCP: + result = vc_handle_rdtsc(ghcb, ctxt, exit_code); break; case SVM_EXIT_RDPMC: result = vc_handle_rdpmc(ghcb, ctxt); -- 2.17.1