Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4647881ybb; Tue, 7 Apr 2020 11:33:34 -0700 (PDT) X-Google-Smtp-Source: APiQypLY2Tdu3c4x0/b4Rq295cx7KGGiMT6PsjS8N1oAfrqvHAA8gk0HgGsFnvDV/yueC+5cZg5q X-Received: by 2002:a05:6830:4038:: with SMTP id i24mr2856617ots.0.1586284414358; Tue, 07 Apr 2020 11:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586284414; cv=none; d=google.com; s=arc-20160816; b=daFgL4xgUjfFpnlB2RDhM8WEMoM45mnHXgnqzUaWuae/lHbrhWNMcdkf87aCF2StmI Gfy760afBhqYC6G7NPP2PllwCO8YXh28pYRzR5zaMyfUzYNCASLya3kFzzDcvEsUvpC/ 660AW+Y+b2xr9p5Ibk/BE3oM//d/Hn0ueTOvBxrAXLe+kaByXcepALUg4VcaHGadsDeT oydv74fxF+GDG4h9h0yL2U54wlr5Fs2ZQ15Cf4yxg9dt/O5tSGbxKwc363DJFXdqogMD f2tz7Fkml0EMmxYXPaW0ncJkn6x9wXtEyExpEXCLFCncen563GJEkpHK7LdltShYTqfC 1KSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=rDMA5WWn7bYB7MG4VGJuqHxYro2AVItySrW1xoxllWc=; b=PAqO80HuGiOYg9a8HsFXBayel/KVumcgsNRITRmFysD+JT7JGidspE8U9JSLcOmp2s bdKBjXcVWGpf8WLz58dMRQhmYLEWgdkAcM9wUwD48kUglszKVXPzVZxINn+Ywxn9NXhb 5McFOJ6Memvch4xHc8sDmzJw/iLp3bi5oPNaNRqQsrUyllx5dWsMh86ruPc9oXSJ/VLI dLGtBAc6PgeeH78N/41XJ7se1zj8dRbt03nP0d8l7Vgya283UcdJIsGhsEQLcGadZRuh 9q3B7lDhS8MV3ofqoDtGpaVGfeLKoI/tR81JqHMwoAs8NKOD4VVo9515SWALjmSAigzf 1vyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@juliacomputing-com.20150623.gappssmtp.com header.s=20150623 header.b=1EBMFcJD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y124si1036974oig.60.2020.04.07.11.33.18; Tue, 07 Apr 2020 11:33:34 -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; dkim=pass header.i=@juliacomputing-com.20150623.gappssmtp.com header.s=20150623 header.b=1EBMFcJD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726723AbgDGSaw (ORCPT + 99 others); Tue, 7 Apr 2020 14:30:52 -0400 Received: from mail-il1-f194.google.com ([209.85.166.194]:46140 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727149AbgDGSau (ORCPT ); Tue, 7 Apr 2020 14:30:50 -0400 Received: by mail-il1-f194.google.com with SMTP id i75so4172128ild.13 for ; Tue, 07 Apr 2020 11:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=juliacomputing-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=rDMA5WWn7bYB7MG4VGJuqHxYro2AVItySrW1xoxllWc=; b=1EBMFcJDgJCUOFSoZbm9gK1yN+paSHk6GKvf6+7Eggkdr9ZuDdu5fTQRHpNz326Uak ZUm5vP29+VIbKDclnFrF8Rz3IV2fp7iRHXshWxXWvZxwEc5RI8zG2VgEvXz7+r1cL3N4 fo27h/b/Bpz+k2NVbBw+RYh2jqfg95ctsXS5yp5qXp7S00T/HuE90IVeux9x1PYvaGT/ /HT/a11YwB2HxQXwEtjecCgAGBQJ7DN9davuW2LhfAkjMZ3oTJ0rJ2D74WXnkANGquE2 LpMQoFmOOqDIIkle22uTY57uGsA8osb0FBvcE7tUv7eKkmJ/xQyRpxiI20HoykJa975W wATw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=rDMA5WWn7bYB7MG4VGJuqHxYro2AVItySrW1xoxllWc=; b=pYUo0useMjqED+Pt01o/sGYRL0RmuNgYAC2/M4/SPBJNTODUicRCzgeybbtkGF4Z1Q 0YUXE4j3rk7UJVwyuUgikTiLxxruD2dNrzgWmARjL1KdHFAFM9M/p3joZUQfFDMQ/YHT 0HpuWDWs0Bx6b6df9tgUZJ91zMe+KCqFmViO6e9dCB0qtnustUEC6UqSO6VXq/FLLjSL DDQXmYyJ86qGhTj6ih33hJ6t6nCUcOT8yICWpLVS5lWqScXp1zVCLwUStnyok7orCyIY ES1xgTSrZsFsWoA512CUoAQn3mrnAEyVyMcZh4nbfu/q5p/4njuTxK4VtumYXopLsPOj uqtQ== X-Gm-Message-State: AGi0PuapMm+gVwdOiaqBVUrT/vI2Rc5GsJAbnzNKRyxYUj5VcMh8WPsu pSf9EmE9vOubdjoN156LQdY9+l9rHvOXFHPWGfZDKg== X-Received: by 2002:a92:cf50:: with SMTP id c16mr3855767ilr.181.1586284249367; Tue, 07 Apr 2020 11:30:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Keno Fischer Date: Tue, 7 Apr 2020 14:30:13 -0400 Message-ID: Subject: Re: [RFC PATCH v2] x86/arch_prctl: Add ARCH_SET_XCR0 to set XCR0 per-thread To: Andy Lutomirski Cc: Dave Hansen , Peter Zijlstra , Linux Kernel Mailing List , Thomas Gleixner , Ingo Molnar , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , Borislav Petkov , Dave Hansen , Andi Kleen , Kyle Huey , "Robert O'Callahan" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > TSX! Yes, it's problematic, but luckily turns out to be ok in practice if masked off in cpuid. > I think rr should give the raw KVM API at least a try. It should be poss= ible to fire up a vCPU in CPL3 in the correct state. No guest kernel requi= red. I don=E2=80=99t know if there will be issues with the perf API, thoug= h. Yes, I've looked into it, but stopped short of doing a complete implementation. Using KVM to solve it for replay would probably be feasible with a moderate amount of engineering work, since rr does very few syscalls during replay. I'm a bit afraid of the performance implications, but I don't have numbers on this. Record and diversions are a lot harder though, because in this mode the tracee is a live process and able to do syscalls (and needs to receive signals and all that good stuff associated with being a real process). For diversions, performance isn't super important, so we could probably emulate this, but for record, performance is quite critical. I assume it would be possible to add a feature to KVM where it forwards syscalls made in guest CPL3 to the real kernel without round-trip through userspace, but I'm just seeing myself back here asking for a weird KVM feature that nobody but me wants ;) (well almost nobody, as I mentioned, there's an academic project that tried this with a custom kernel plugin - http://dune.scs.stanford.edu/). Admittedly, the use case for this feature during record is less pressing, since in our (operational) case the replay machines tend to be much newer than the record machines, but I wouldn't be surprised if I got bit by this as soon as the next user xstate component gets added and users start sending me those kinds of traces, even if we mask off the feature in CPUID (which rr already supports for record for similar reasons).