Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5198882imm; Tue, 19 Jun 2018 06:44:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJRIymrpWb+6uoWVTq6pV4zWGW59CrY/JCkf0MbDvO09YvyCklDgGG0vS3bGLC9+6ygarrC X-Received: by 2002:a63:27c6:: with SMTP id n189-v6mr15106203pgn.164.1529415879757; Tue, 19 Jun 2018 06:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529415879; cv=none; d=google.com; s=arc-20160816; b=TBFtHMUKfy1Qd9qUO7A8vvkbWGlJQYUY+Ta9I4GGKNw0iQgbCajCoFKswVXjvSTjnj v7CptI87qoTx8zWJvl84GYpnH0tswr1MAyWhi56q5JYEbHwWAUZPaiYK+EXElrGfc287 kupmgYpYYg7CDQRVqDR7p956IqurtQleQLsiDzrBn1WeuZeZBhOYBmTRXUTjVQwaq3bX iDXsIp77TZktnib60I1ncBBPLer3OCCTp2alslLr6PznacdQ3XQ4oY2VfmpqljbRrDlV 2kpaDTw1q3eLbQUPXa5obGvEujBrNpWAdml1LBGHuybFrDilqUQMlE3rgcRun2Ok880C 8IfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=nuQDLgGjxKu45EcS7NtZh99w1D4uHyFdhzZDlIw9GsQ=; b=EAXTx2LY9q5x7Qj0u4h9aosdJGvjRDASMJbXZms/sVwn/YafFcy1/VQKTl+8chfNq/ 4XjLTxEhfSq9YAIKuU94s780yw9zWgmBJlmmlkcQs/GkTbMGYzBr7aL6/oO47p4nqwlA INLirtTQsc6a5jujZfFPKm3z58aJ32nOUAvrZL9jV6L+69YJQy40LAZtl3aX/UuCy09b no7TWLD6O7NZV/S+lPhBqugR3sm5Gx6M7LZ2ogkdrKBfzuU8md0gyWaMzxcbEMHZMhO5 CjLeGLuUZ0ZUMh9pq7Ba4h4UejoqhdnBYX4y94D0vkwodA/sTir3AjTp+jxqvmNJ2gab R9CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@firstfloor.org header.s=mail header.b=CpnN0wRF; 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 i65-v6si17033556pfg.218.2018.06.19.06.44.26; Tue, 19 Jun 2018 06:44:39 -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=@firstfloor.org header.s=mail header.b=CpnN0wRF; 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 S966124AbeFSNns (ORCPT + 99 others); Tue, 19 Jun 2018 09:43:48 -0400 Received: from one.firstfloor.org ([193.170.194.197]:49022 "EHLO one.firstfloor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965592AbeFSNnr (ORCPT ); Tue, 19 Jun 2018 09:43:47 -0400 Received: by one.firstfloor.org (Postfix, from userid 503) id A4F1D86A14; Tue, 19 Jun 2018 15:43:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=firstfloor.org; s=mail; t=1529415825; bh=nuQDLgGjxKu45EcS7NtZh99w1D4uHyFdhzZDlIw9GsQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CpnN0wRFV/Xk8a+a1COkGtX+Q2oi9BpN6AW9/XTcKZmmnfz00k7COjOlsHKzajG2G R6PQClk30cuFTaS65dnAJjHxnjPShAWztqzNW6UP/cy1mHnKpnS0pzds1wq7+YP2sH qOVM29BnqNdfrg3aRHUlfPd5ga4zd3vl1EMotoLY= Date: Tue, 19 Jun 2018 06:43:45 -0700 From: Andi Kleen To: Keno Fischer Cc: Andi Kleen , Linux Kernel Mailing List , Thomas Gleixner , Ingo Molnar , x86@kernel.org, "H. Peter Anvin" , Borislav Petkov , Dave Hansen , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Kyle Huey , Robert O'Callahan Subject: Re: [RFC PATCH] x86/arch_prctl: Add ARCH_SET_XCR0 to mask XCR0 per-thread Message-ID: <20180619134345.azpifnsmgd5dprhu@two.firstfloor.org> References: <1529195582-64207-1-git-send-email-keno@alumni.harvard.edu> <20180617163530.rvwf7fcukmoletgo@two.firstfloor.org> <20180618165840.gikljqhaxtiiw27x@two.firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > In particular 1) means that any extra instructions executed/not executed > will cause a replay divergence (in practice rr uses retired conditional > branches rather than instructions, because the instruction counter is > not accurate, while the branch one is). This alone causes a problem > for the present case, because glibc branches on the xcr0 value before > it branches on the cpuid value for AVX512. Glibc does check for the > correct cpuid before calling xgetbv, so one possible thing to do is to > completely disable xsave during recording by disabling it in CPUID, but > that would make rr quite a bit less useful, since it wouldn't be able to Ah I see it now. This problem was introduced with the changes for glibc to save AVX registers using XSAVE instead of manually. It still seems this has a straight forward fix in glibc though. It could always allocate the worst case buffer, and also verify XGETBV against CPUID first. I'm sure this can be done in a way that executed branches don't differ. AFAIK manual use of XSAVE is not that common, so hopefully these problems are not wide spread in other programs. Of course longer term you'll just need to have matching ISAs in record and replay. Trying to patch around this is likely always difficult. -Andi