Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp414548rdb; Sat, 19 Aug 2023 06:57:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7vGQcIy5QmZjvKgDwcDCXbuPH2qpbSMZFy3ltOlRWjsIrUcFdGF1Jp5kkOKIvcg8REXmP X-Received: by 2002:a17:903:32c1:b0:1bf:349f:b85c with SMTP id i1-20020a17090332c100b001bf349fb85cmr2491235plr.1.1692453477056; Sat, 19 Aug 2023 06:57:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692453477; cv=none; d=google.com; s=arc-20160816; b=IAXfyddEi+GV7vAS5ZVNXo065wfuRUaXHAeU/cTmRex5OSiwWIL+S6VSYCNlVft5r8 AjPuvyN2OaqTXqLTYVisrT//q6LtvYlSf6VeI9l7bLH+tncY063svEOhnKbwZPMhyhNO 7TuWKclRiB/iwCgi03Vwiiyks4uJBKr4sz/tGjedGi/MECWvmivGzGwgXplfJ1RKOiEF oqealMQmR4/f+SIzL9XIRv7KIF0LzRZ2LeJhnbl+8/p8Sjr7ywQhuPnbaJyRDJh4y11S Lc+LH5H41K6v0V/21nacGC4St7oIHz59pRce0CmLW7Z5wd9w+6n0+GMMezQ7grDi+o22 j14A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:dkim-signature; bh=jX7V1lWluewhSh6VMm5HNZIM42OiPORMFCW/iRk3n2s=; fh=OvKVVz6scunl8xjQQdca24ugMJXiWLJMX1Ic6Kja6Tw=; b=RIMnEdKx+X+905NKWw0FHy/aNKJ9c4JckSHDUZv1xTcWAZnXPSi0nF1BNAXekPKAT8 S0wVXi+TjeJPYFeU76xGQH8mXT9bqYWJHpUSqszr5DOiZDLwT0XPws02kzzxrXasvlb1 C6GsB20rKV7stVxlm3WiLrNfe3IuukAP/H8aRG9A4PnGQIO+v1yYn1mzgpG5wThmD0Me jfxfBzdEA16jSHXN8cx/LmM7e8idn3qbDlp7I+bq46heZ3/vxNAEsKmOdbLP3h0GuMpE u8GTGCt9e/6Wky+Z8oqqycPHtcxfCcOCZYW2hjhIpIJ35/bk6Zv9PB622uRlIzotY+bd abCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=cccuvca1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d15-20020a170902654f00b001bbd83490efsi322995pln.138.2023.08.19.06.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 06:57:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=cccuvca1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA06DB52F8; Sat, 19 Aug 2023 01:42:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343772AbjHPOjw (ORCPT + 99 others); Wed, 16 Aug 2023 10:39:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343780AbjHPOj3 (ORCPT ); Wed, 16 Aug 2023 10:39:29 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 084BA2D65 for ; Wed, 16 Aug 2023 07:39:03 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d637af9a981so7317809276.0 for ; Wed, 16 Aug 2023 07:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692196741; x=1692801541; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=jX7V1lWluewhSh6VMm5HNZIM42OiPORMFCW/iRk3n2s=; b=cccuvca16nyqVbTT+p9NSMZsvpgmLzaCavWmkhGRspARsQI445ljxYnl/xM9pXE9iq kI1541LdnXukuAuL73uLvN7Z7Lk0yrcLeeThM7TABW+xSp+QemBd0jzVoR/ZWyJfKz9O MwzWLAaDVQZGFMq9TF/+TfgKNe1ajrgF8PYwJVDSP1jDRVxXWvs0VFjyXdI+wEs9UqZp 5WEpenVLKOKBbAentiDPY7WJq7kFfz14K0uY1+hJzNr/QtnnDD8VqI2z3K0ex2OSncm2 X9qrvzbUrOYBzk5wstwOwcINpjuqoXdeccyAWWi4yAdY6B5HA1LeEsQ6+5pVY8Ur1LQx RoKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692196741; x=1692801541; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=jX7V1lWluewhSh6VMm5HNZIM42OiPORMFCW/iRk3n2s=; b=IZ7EKnqM4WJYU6IXCkN9Fhx8Y20zzJ3D7TIIyKtVa/MLVvyiBQ9HMaY9l+gNz1l8VO UqbcVt28+nFvxDPNE+5mlR6Ni/DRjWH48MUnoF1xynJFyu+0ChC7mRxKdFiz9HquEBey vr66WBTmGFpS566Ku0CQA53PXAsvJ3JZA3QTc8N3iMhCCW/C8hd+XYAssuDbxCJinwF9 6fizXHATNjX5mUoXFxqZo8Y+tzt51+IpS2sGW8+SxbjNEe+7FNn3P0nHXtKcg5t5A4/7 YxW2ITv7S1aHzlzW7UF6mEQMxNikDe8gLP0+LcR6dTw/ZBRtFIjAZtX8yo2gW3LZ+StH Yndg== X-Gm-Message-State: AOJu0Yx1X3wmUP43IbBpMtHMiR0oXo3pPyu7jagUwydyLIlcbKAYKlNj gpVnENWMh144dnpyeRjHtZ5bZA22JBE= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:b901:0:b0:d71:36b5:e9ee with SMTP id x1-20020a25b901000000b00d7136b5e9eemr33704ybj.8.1692196740878; Wed, 16 Aug 2023 07:39:00 -0700 (PDT) Date: Wed, 16 Aug 2023 07:38:59 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230719024558.8539-1-guang.zeng@intel.com> <20230719024558.8539-3-guang.zeng@intel.com> Message-ID: Subject: Re: [PATCH v2 2/8] KVM: x86: Use a new flag for branch instructions From: Sean Christopherson To: Binbin Wu Cc: Zeng Guang , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , H Peter Anvin , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 16, 2023, Binbin Wu wrote: >=20 >=20 > On 8/16/2023 6:51 AM, Sean Christopherson wrote: > > Branch *targets*, not branch instructions. > >=20 > > On Wed, Jul 19, 2023, Zeng Guang wrote: > > > From: Binbin Wu > > >=20 > > > Use the new flag X86EMUL_F_BRANCH instead of X86EMUL_F_FETCH in > > > assign_eip(), since strictly speaking it is not behavior of instructi= on > > > fetch. > > Eh, I'd just drop this paragraph, as evidenced by this code existing as= -is for > > years, we wouldn't introduce X86EMUL_F_BRANCH just because resolving a = branch > > target isn't strictly an instruction fetch. > >=20 > > > Another reason is to distinguish instruction fetch and execution of b= ranch > > > instruction for feature(s) that handle differently on them. > > Similar to the shortlog, it's about computing the branch target, not ex= ecuting a > > branch instruction. That distinction matters, e.g. a Jcc that is not t= aken will > > *not* follow the branch target, but the instruction is still *executed*= . And there > > exist instructions that compute branch targets, but aren't what most pe= ople would > > typically consider a branch instruction, e.g. XBEGIN. > >=20 > > > Branch instruction is not data access instruction, so skip checking a= gainst > > > execute-only code segment as instruction fetch. > > Rather than call out individual use case, I would simply state that as = of this > > patch, X86EMUL_F_BRANCH and X86EMUL_F_FETCH are identical as far as KVM= is > > concernered. That let's the reader know that (a) there's no intended c= hange in > > behavior and (b) that the intent is to effectively split all consumptio= n of > > X86EMUL_F_FETCH into (X86EMUL_F_FETCH | X86EMUL_F_BRANCH). >=20 > How about this: >=20 > =C2=A0=C2=A0=C2=A0 KVM: x86: Use a new flag for branch targets >=20 > =C2=A0=C2=A0=C2=A0 Use the new flag X86EMUL_F_BRANCH instead of X86EMUL_F= _FETCH in > assign_eip() > =C2=A0=C2=A0=C2=A0 to distinguish instruction fetch and branch target com= putation for > feature(s) Just "features", i.e. no parentheses... > =C2=A0=C2=A0=C2=A0 that handle differently on them. ...and tack on ", e.g. LASS and LAM." at the end. There's zero reason not = to more explicitly call out why the flag is being added. Trying to predict the fut= ure in changelogs is generally discouraged, but having understandable changelogs i= s more important. > =C2=A0=C2=A0=C2=A0 As of this patch, X86EMUL_F_BRANCH and X86EMUL_F_FETCH= are identical as > far as > =C2=A0=C2=A0=C2=A0 KVM is concernered. >=20 > =C2=A0=C2=A0=C2=A0 No functional change intended. Heh, you need to fix whatever is forcefully wrapping lines, but other than = the nit above, the content itself is good.