Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2027588pxa; Mon, 24 Aug 2020 03:02:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk6tt1XB1hg8DVq/svDsGVG4X3Z3D78pWvIjwPFIjTdAKlN2vW0h/jBnHDx3CLKlO7ftu2 X-Received: by 2002:a17:906:49a:: with SMTP id f26mr4702188eja.266.1598263351752; Mon, 24 Aug 2020 03:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598263351; cv=none; d=google.com; s=arc-20160816; b=KDzsyxGICyZNkI5XGsRFeolW6zSCEIyETfCyTcDjul5OinXDkkf0AQd61RvaL7z8A0 Qy3h1afo4NNbLkR+lTjSuh7YMCS7tz+yEnGtuClndXeNSN+HqrTd/VC28uTnZjBJAKEP M5otTjsv42CWD/VwBVbwvUbXFk2pbKY1gicxH1Qli9hsVDQF/mD3W025IriE4V/S3nZV KaZg3bMQy+jMqxNQRvReVH967fYFsP1JOACk/Od60JaIs6XgYc3XflW4EJc7dovmwbD0 biZLH6h7QPZDa17gCz7JUvRYwb9zMjJjDTnUToxeJ8fNY6OETMzGw8XMPl5LAcMOPz4V yx6A== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2rm8zioYtI/3uZPXnQqAsbN+vxxzgERblA21a1gIDEE=; b=VPBhtgj9WR+NaMaFG9MUNjpQdn7qp5fGtryEv3aFO9I6CIeH2irq1Z2ml8lO2AFAJI VfjHSNVqmuux0bIKaKXO2JqqNhAyJ66ednIdS5zJv2pTkSIAaDeV69MKxRkNoGHP3XmS NJ0bBhPGuselp1nMLUgvPap/k3eIHnoZLSnvDBBZwPPgLrlq1IjLhG6rondZ0AZZkBNy DgAvVIyCobzvKf3ARvpIbu1ARLaGbZUCZUbHiemm7bNYNQrm1+ua166MLWKcTDi1Zfod Efef8ZyT/eS1UFQgV5PFo+YbA5b1DHvfGSd4N4+9kw2lxmOkvox4N5pxZc8P18bEqLhr taoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LlVQrELT; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si3775526edn.575.2020.08.24.03.02.08; Mon, 24 Aug 2020 03:02:31 -0700 (PDT) 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=@kernel.org header.s=default header.b=LlVQrELT; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729124AbgHXJ7y (ORCPT + 99 others); Mon, 24 Aug 2020 05:59:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:40290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726873AbgHXIdA (ORCPT ); Mon, 24 Aug 2020 04:33:00 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 70762206F0; Mon, 24 Aug 2020 08:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598257980; bh=lVVAh9Z9McLW3SoXxl5P+4DwQWEYitbI4AmCQQ3aerw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LlVQrELTLpGyA0Nb8FpolZ+vOVwma5sBDGd+0ec0iStlvvKA9G64YvLeipqwYvTjh fOZUjpxe1AbWNiLFTNqXEvdHeFFQHsJhBqPo3fGZSZuzE5FUuP/VN2VvvAkFRHJV/K 4ZeKI2oeiXADPLX1j7E6S47SuaMQemnBEpTz4fUc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Weijiang , Paolo Bonzini Subject: [PATCH 5.8 030/148] selftests: kvm: Use a shorter encoding to clear RAX Date: Mon, 24 Aug 2020 10:28:48 +0200 Message-Id: <20200824082415.398316113@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200824082413.900489417@linuxfoundation.org> References: <20200824082413.900489417@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Weijiang commit 98b0bf02738004829d7e26d6cb47b2e469aaba86 upstream. If debug_regs.c is built with newer binutils, the resulting binary is "optimized" by the assembler: asm volatile("ss_start: " "xor %%rax,%%rax\n\t" "cpuid\n\t" "movl $0x1a0,%%ecx\n\t" "rdmsr\n\t" : : : "rax", "ecx"); is translated to : 000000000040194e : 40194e: 31 c0 xor %eax,%eax <----- rax->eax? 401950: 0f a2 cpuid 401952: b9 a0 01 00 00 mov $0x1a0,%ecx 401957: 0f 32 rdmsr As you can see rax is replaced with eax in target binary code. This causes a difference is the length of xor instruction (2 Byte vs 3 Byte), and makes the hard-coded instruction length check fail: /* Instruction lengths starting at ss_start */ int ss_size[4] = { 3, /* xor */ <-------- 2 or 3? 2, /* cpuid */ 5, /* mov */ 2, /* rdmsr */ }; Encode the shorter version directly and, while at it, fix the "clobbers" of the asm. Cc: stable@vger.kernel.org Signed-off-by: Yang Weijiang Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- tools/testing/selftests/kvm/x86_64/debug_regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/tools/testing/selftests/kvm/x86_64/debug_regs.c +++ b/tools/testing/selftests/kvm/x86_64/debug_regs.c @@ -40,11 +40,11 @@ static void guest_code(void) /* Single step test, covers 2 basic instructions and 2 emulated */ asm volatile("ss_start: " - "xor %%rax,%%rax\n\t" + "xor %%eax,%%eax\n\t" "cpuid\n\t" "movl $0x1a0,%%ecx\n\t" "rdmsr\n\t" - : : : "rax", "ecx"); + : : : "eax", "ebx", "ecx", "edx"); /* DR6.BD test */ asm volatile("bd_start: mov %%dr0, %%rax" : : : "rax");