From patchwork Wed Aug 22 10:03:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 179280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 28DA92C0096 for ; Wed, 22 Aug 2012 20:04:32 +1000 (EST) Received: from localhost ([::1]:47164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T47na-0003qs-6j for incoming@patchwork.ozlabs.org; Wed, 22 Aug 2012 06:04:30 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T47nO-0003q3-Gb for qemu-devel@nongnu.org; Wed, 22 Aug 2012 06:04:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T47nI-0003Gf-L9 for qemu-devel@nongnu.org; Wed, 22 Aug 2012 06:04:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T47nI-0003GT-C6 for qemu-devel@nongnu.org; Wed, 22 Aug 2012 06:04:12 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7MA3sPG004795 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 22 Aug 2012 06:03:55 -0400 Received: from balrog.usersys.tlv.redhat.com (dhcp-4-121.tlv.redhat.com [10.35.4.121]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q7MA3mvZ005717; Wed, 22 Aug 2012 06:03:49 -0400 Message-ID: <5034AE84.90708@redhat.com> Date: Wed, 22 Aug 2012 13:03:48 +0300 From: Avi Kivity User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Tomas Racek , the arch/x86 maintainers References: <592618508.2357204.1345541334852.JavaMail.root@redhat.com> <5034AC61.9030704@redhat.com> In-Reply-To: <5034AC61.9030704@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kvm-devel , qemu-devel@nongnu.org, Marcelo Tosatti , Michael Tokarev , linux-kernel , Borislav Petkov , Anthony Liguori , "H. Peter Anvin" , Alan Cox , Alan Cox Subject: [Qemu-devel] [PATCH] x86, alternative: fix p6 nops on non-modular kernels X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 08/22/2012 12:54 PM, Avi Kivity wrote: > On 08/21/2012 12:28 PM, Tomas Racek wrote: >> >> http://fi.muni.cz/~xracek/debian2.img.bz2 >> >> Other things are the same. >> >> The runtest.sh sets environment for xfstests and runs test 285 which I wrote and and which should test if FS sends discard requests only on free sectors: >> 285: >> 1. Create loop device and FS on it. >> 2. Populate it with some garbage. >> 3. Get free sectors from FS. >> 4. Run fstrim and look for discard requests via blk tracer. >> 5. Compare free sectors to discard requests. >> >> The test itself can have some issues but I'm pretty sure it shouldn't crash the system. ;-) > > Does the following patch help? > It's obvious that it should. You're running a non-modular kernel, and those nops are discarded (probably a leftover from the days patching was a boot-only activity), so the kernel patched garbage over its own code. -------8<----cut-here-----8<----------------------------------- From: Avi Kivity Date: Wed, 22 Aug 2012 12:58:18 +0300 Subject: [PATCH] x86, alternative: fix p6 nops on non-modular kernels Probably a leftover from the early days of self-patching, p6nops are marked __initconst_or_module, which causes them to be discarded in a non-modular kernel. If something later triggers patching, it will overwrite kernel code with garbage. Reported-by: Tomas Racek Signed-off-by: Avi Kivity diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index afb7ff7..ced4534 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -165,7 +165,7 @@ static int __init setup_noreplace_paravirt(char *str) #endif #ifdef P6_NOP1 -static const unsigned char __initconst_or_module p6nops[] = +static const unsigned char p6nops[] = { P6_NOP1, P6_NOP2,