Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5968764pxu; Wed, 23 Dec 2020 09:47:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWlTvhs18AJDgQcDMsCB0re1CeNbIqGjPmS9WV78YDLsMdA5CdH123raGK49yg+py8qa0U X-Received: by 2002:aa7:cac2:: with SMTP id l2mr25536255edt.141.1608745635264; Wed, 23 Dec 2020 09:47:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608745635; cv=none; d=google.com; s=arc-20160816; b=klBqy630Elyv2mFwiKya5Zb72sDwqnTrYV7Nf5K6eYu5jX5ENq0q5WhBdo8CgOxYzp QsLvYs7iy8WZEzOqLOuy4h+Z8CjjDhYrscLlAkz+XGhK0Xv2ZeN4L2DlwBCfJ4CUiSw2 f11mhrsgVDBqMwAk97lLtaqciezBOVCm65M0NDgjpG85Vg7RWgt2Mp5sCwOfJ41Lq8TW aryZr8Sfem7t8UoluvYUv8u974hU4Umnga5LqcNHpbDlRhZKkGAkrym9Ab+2CeW5nfSL QwDFkWwWn+d7dUOIkdcK7BRwVxTkXbZvNb2nemEnNdMOKvkOkw8HrKgWkboEAHGIFvAl Di4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dn7xdOixbJ18iX/uu48fTyX8QZ8h+c1ptsOI2BGg9UA=; b=DnaU/0tMDD/Ra4AiIjVh9zcczf+wTEK/B19rZm/IgRD9af3AwfDHx1UxC/6E5hIf2C H2mw+ugWtmEguCsHCpzKjdDqDarY2UnGVKpjhBujE3X/atY0JlnYv093LjDMbY8161uw dL+A+8/dEsP9lJY6z3SCWMhf9Is7HvOKgRZ9p3pZcimwIHYKVFO6XSOC4D6qWN8XyX0I iwOrWwVeTYtND6p117dX+3kstpAjbimrA8YvnCVeZx8VpdskgKzkK4lmMXMZTnRCcku9 qMPWCjlcz2GIet+8NTN5Aiu4WPzBEFwqMlQ7ZGGDUWO3cG8o3jpANqyREVYDukBzAtK7 Urmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=ZZDYVYp+; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c25si13484933edw.609.2020.12.23.09.46.52; Wed, 23 Dec 2020 09:47:15 -0800 (PST) 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=@alien8.de header.s=dkim header.b=ZZDYVYp+; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727884AbgLWRnZ (ORCPT + 99 others); Wed, 23 Dec 2020 12:43:25 -0500 Received: from mail.skyhub.de ([5.9.137.197]:39422 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727802AbgLWRnZ (ORCPT ); Wed, 23 Dec 2020 12:43:25 -0500 Received: from zn.tnic (p200300ec2f0de600b74d534b1676c98b.dip0.t-ipconnect.de [IPv6:2003:ec:2f0d:e600:b74d:534b:1676:c98b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 480A21EC0527; Wed, 23 Dec 2020 18:42:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1608745364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dn7xdOixbJ18iX/uu48fTyX8QZ8h+c1ptsOI2BGg9UA=; b=ZZDYVYp+rzAXOpeIqUwzoRrg59G3GihctzqSZUGyjXo0i2dFV5Y56LHLdkVz3DT2d7t9AI x9GWO+336/YjyrdUXZ5wlN1jmqDJkjSmWi2PJK7x7BZZ4Erd9i1ivoqD9kfoICRd4jt58c qxMtfYq2cCAFXAtoUsEeLfCmpxHGOvQ= From: Borislav Petkov To: Andy Lutomirski , Masami Hiramatsu Cc: X86 ML , LKML Subject: [PATCH v1 05/19] x86/boot/compressed/sev-es: Convert to insn_decode() Date: Wed, 23 Dec 2020 18:42:19 +0100 Message-Id: <20201223174233.28638-6-bp@alien8.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201223174233.28638-1-bp@alien8.de> References: <20201223174233.28638-1-bp@alien8.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov Other than simplifying the code there should be no functional changes resulting from this. Signed-off-by: Borislav Petkov --- arch/x86/boot/compressed/sev-es.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/x86/boot/compressed/sev-es.c b/arch/x86/boot/compressed/sev-es.c index 27826c265aab..801c626fc3d4 100644 --- a/arch/x86/boot/compressed/sev-es.c +++ b/arch/x86/boot/compressed/sev-es.c @@ -78,16 +78,15 @@ static inline void sev_es_wr_ghcb_msr(u64 val) static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt) { char buffer[MAX_INSN_SIZE]; - enum es_result ret; + int ret; memcpy(buffer, (unsigned char *)ctxt->regs->ip, MAX_INSN_SIZE); - insn_init(&ctxt->insn, buffer, MAX_INSN_SIZE, 1); - insn_get_length(&ctxt->insn); + ret = insn_decode(&ctxt->insn, buffer, MAX_INSN_SIZE, INSN_MODE_64); + if (ret < 0) + return ES_DECODE_FAILED; - ret = ctxt->insn.immediate.got ? ES_OK : ES_DECODE_FAILED; - - return ret; + return ES_OK; } static enum es_result vc_write_mem(struct es_em_ctxt *ctxt, -- 2.29.2