Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5967655pxu; Wed, 23 Dec 2020 09:45:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjrIE2MRYKsGNtTr3WZS23bB9lGUC02qwFpvk3BAiD8GVweCxkrjTTfAA8IBp6LbxVf3st X-Received: by 2002:a17:906:234d:: with SMTP id m13mr25247253eja.270.1608745529253; Wed, 23 Dec 2020 09:45:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608745529; cv=none; d=google.com; s=arc-20160816; b=tbg+/Mz/BVYIlHukjCdRaSPRNy92cF9TkicN7o5TqL3FfPjy7uMZKKCZ3I4m1O7G9o OH4PjiwB2WEferkV5FFXbkgD+t+0Fy4fjrJje6UnBX9CzgPMDFG+xeSpzUhQyPuS3Qwl FxdEpsywqcPHFL0VfEsbsA/Fmo1e8jk84kRNhYtc4z32RvwGZLoyIHMLB1NU4iLlPRts sDaBkISIUxpG2vjsHy3Enei9vuHFx+hiAe+kWhwVZ/cBMH3BIgldIsPjYnfb6PlBSaow s/AJvbKnFTqCW9B2ZmHwKqxR5bZ0APlf2RB9C0yGGcYPC4NXOKJzvAvxYPUmx34A8zXH qgUg== 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=+NaPAg2Mqrevy0pOLY7SFPtAdYDDXm3mlVRRt9/3A+E=; b=HEuxV1s2Pk8cpe5CXa2A1fNrbmyAU4+v8ICSuFR0+dhUmcNvSk7RdQecxtyRlnfplH 0O/LaE/qX95wRY8C7flpn/F2AHMjQ1pBODNss38PEJgEuSz1sRHguWGGukmWVgtLk9lM zXDPDr9qm1m+5xMLiHaaOASvMhGJUsVuDv+VEhulMITLNpJgTuda19KGri47jHdDSOSu 1c6r3g5qitj5zLTuZ6uAZ7wr4yHjcEZZloyosA5uiFi3Zke+7HaylsML3TV+71xaqX+k cplduse6ohWx2/3hV+ZXqijnvf2B4jqiLMDCsQoWuEVi3nHLzg/K5m92oxVGQEyrUcpx /Frg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=N+3lfNVP; 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 dt1si14171820ejc.558.2020.12.23.09.45.04; Wed, 23 Dec 2020 09:45:29 -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=N+3lfNVP; 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 S1728470AbgLWRnp (ORCPT + 99 others); Wed, 23 Dec 2020 12:43:45 -0500 Received: from mail.skyhub.de ([5.9.137.197]:39540 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728123AbgLWRn3 (ORCPT ); Wed, 23 Dec 2020 12:43:29 -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 9F6FF1EC052C; Wed, 23 Dec 2020 18:42:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1608745368; 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=+NaPAg2Mqrevy0pOLY7SFPtAdYDDXm3mlVRRt9/3A+E=; b=N+3lfNVPNN38z8lJLC0Kaukay3stdDez3qaPcKk0860HNZXjJsWtxnn8CDdEzRJfYDmbIS yCN5mcSrpVbGhR/rlekysjpk++OjONEVKhzccoBuA8t+OAmegmjVEeL1t1i1Qa4rCzN85h 3sePhOt9KNwcqv7RKy+EViVKp00F1jw= From: Borislav Petkov To: Andy Lutomirski , Masami Hiramatsu Cc: X86 ML , LKML Subject: [PATCH v1 11/19] x86/sev-es: Convert to insn_decode() Date: Wed, 23 Dec 2020 18:42:25 +0100 Message-Id: <20201223174233.28638-12-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 Simplify code, no functional changes. Signed-off-by: Borislav Petkov --- arch/x86/kernel/sev-es.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/sev-es.c b/arch/x86/kernel/sev-es.c index 37736486603e..564cc9fc693d 100644 --- a/arch/x86/kernel/sev-es.c +++ b/arch/x86/kernel/sev-es.c @@ -244,8 +244,7 @@ static int vc_fetch_insn_kernel(struct es_em_ctxt *ctxt, static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt) { char buffer[MAX_INSN_SIZE]; - enum es_result ret; - int res; + int res, ret; if (user_mode(ctxt->regs)) { res = insn_fetch_from_user(ctxt->regs, buffer); @@ -267,13 +266,13 @@ static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt) return ES_EXCEPTION; } - insn_init(&ctxt->insn, buffer, MAX_INSN_SIZE - res, 1); - insn_get_length(&ctxt->insn); + ret = insn_decode(&ctxt->insn, buffer, MAX_INSN_SIZE - res, INSN_MODE_64); } - ret = ctxt->insn.immediate.got ? ES_OK : ES_DECODE_FAILED; - - return ret; + if (ret < 0) + return ES_DECODE_FAILED; + else + return ES_OK; } static enum es_result vc_write_mem(struct es_em_ctxt *ctxt, -- 2.29.2