Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp373593pxb; Thu, 21 Jan 2021 09:04:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwD2+IMmaVDcPv1eIxfuWnTdASF9J9NLc6KkrL/7kRmvO27rx82kF36Ny9w56y6AqMqBNIn X-Received: by 2002:a17:906:7d09:: with SMTP id u9mr286233ejo.380.1611248685582; Thu, 21 Jan 2021 09:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611248685; cv=none; d=google.com; s=arc-20160816; b=0B+2rc263O3BkEqfJADj9jTMdmDuZ7c72wICOTRoKMJ91pRstXTPbkPogkvqvDcHAk FTjm8w3usuk4m50ZJwWeLQPSvCsORuMKyHY+8B/5fnOU658juYwXTtFVH41G7GNRKQZU 14n5DVOrJmKf4QgJV1axFCk8YRl9VE7ZG8ZM+QZNQJf3/kHmeDwR/k0rwESTWfhhvinT 5+GrjKIPkq+r9SWkAvqEdS8AasMtkPKIWfjx+Olvqxy1BWid8m/geb77aTi5mNeHJ/qb DCTNe/Oc/uOGN7CuB9xOvBK3O23fYyZeplvr6R4uq+Z6baOgXmzzleIPX2Cds72uv175 etyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aAowCgPKnj8lJNpLWRHPtz+od612hKZl8mosyJYxxbc=; b=rmj2ZKa5LQVUsIi2IXZngyVRKWRvTaVhrsAKyk3jNjQIEMdgAXEQcIJf0gX+HU7sfQ 1NCfHzj6NS28Ayr3VosOQPXo8X9vU4wJ6Epal+2eALSh709ZiiM+FN7jHSTPzTvU532n psdGnwiRc7ybXuTrcuEfYrzjBgL0hk8H5i6qG5hK5IQZvfM3DbDJA9dFTkhdBUYA+FQ7 wxdVFIC5sH2iDyhQAcUmhp4sc4uDZe2WsVqEXiDcqITtY3U/KYA5wbyzAwskfzO17D04 EUpWTAaypfQ1UTbaibi2GD3Way95M0amSPbRHqXr8XLyh8qcBrBop3nrF0MPCtO5SAIs bsPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=PgrGVRVA; 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 hr32si1857563ejc.128.2021.01.21.09.04.20; Thu, 21 Jan 2021 09:04:45 -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=PgrGVRVA; 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 S2388305AbhAUQ7z (ORCPT + 99 others); Thu, 21 Jan 2021 11:59:55 -0500 Received: from mail.skyhub.de ([5.9.137.197]:42588 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732032AbhAUQ7j (ORCPT ); Thu, 21 Jan 2021 11:59:39 -0500 Received: from zn.tnic (p200300ec2f1575008f111d19c272cab6.dip0.t-ipconnect.de [IPv6:2003:ec:2f15:7500:8f11:1d19:c272:cab6]) (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 ECC551EC05C2; Thu, 21 Jan 2021 17:58:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1611248331; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=aAowCgPKnj8lJNpLWRHPtz+od612hKZl8mosyJYxxbc=; b=PgrGVRVA3VMNJUCpJ6bPgsHll8aCYW8clLpzyFLNiDJMVMBToIhgFobxNQ/gmXDhXKfduJ vVrS86Fbs63253wBH6T8TMp/Cc1Pve1xB7XVN27UxbERSrTBADQA50Yha8/KCzcUle6Jpm ce/OcJE+Jx1sG02qNi/2nZLU+QUe3ME= Date: Thu, 21 Jan 2021 17:58:45 +0100 From: Borislav Petkov To: Sean Christopherson Cc: kernel test robot , Andy Lutomirski , Masami Hiramatsu , kbuild-all@lists.01.org, clang-built-linux@googlegroups.com, X86 ML , LKML Subject: Re: [PATCH v1 11/19] x86/sev-es: Convert to insn_decode() Message-ID: <20210121165845.GD32060@zn.tnic> References: <20201223174233.28638-12-bp@alien8.de> <202012251838.G6eufP3Q-lkp@intel.com> <20201225123334.GA5874@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 28, 2020 at 11:15:11AM -0800, Sean Christopherson wrote: > Alternatively, could the kernel case use insn_decode_regs()? If > vc_fetch_insn_kernel() were also modified to mirror insn_fetch_from_user(), the > two code paths could be unified except for the the fetch and the PFEC. E.g. Personal Firearms Eligibility Check? In any case, I prefer simple, easy to follow code at a quick glance. Stuff like... > > static int vc_fetch_insn_kernel(struct es_em_ctxt *ctxt, > unsigned char *buffer) > { > if (copy_from_kernel_nofault(buffer, (unsigned char *)ctxt->regs->ip, MAX_INSN_SIZE)) > return 0; > > return MAX_INSN_SIZE; > } > > static enum es_result vc_decode_insn(struct es_em_ctxt *ctxt) > { > char buffer[MAX_INSN_SIZE]; > int nbytes; > > if (user_mode(ctxt->regs)) > nbytes = insn_fetch_from_user(ctxt->regs, buffer); > else > nbytes = vc_fetch_insn_kernel(ctxt, buffer); > > if (!nbytes) { > ctxt->fi.vector = X86_TRAP_PF; > ctxt->fi.error_code = X86_PF_INSTR; > if (user_mode(ctxt->regs)) ... this second repeated check here is not what I would call that. But this is my personal preference only so it's up for a vote now. :-) -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette