From patchwork Wed Jan 2 12:00:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 209020 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 4E7012C0098 for ; Wed, 2 Jan 2013 23:01:02 +1100 (EST) Received: from localhost ([::1]:55146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqN0E-0005wi-Ti for incoming@patchwork.ozlabs.org; Wed, 02 Jan 2013 07:00:58 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqN06-0005wQ-Cf for qemu-devel@nongnu.org; Wed, 02 Jan 2013 07:00:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TqN05-000682-5E for qemu-devel@nongnu.org; Wed, 02 Jan 2013 07:00:50 -0500 Received: from mail-la0-f52.google.com ([209.85.215.52]:50601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TqN04-00067u-Tc for qemu-devel@nongnu.org; Wed, 02 Jan 2013 07:00:49 -0500 Received: by mail-la0-f52.google.com with SMTP id fq12so5833614lab.39 for ; Wed, 02 Jan 2013 04:00:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:x-gm-message-state; bh=Pb67bADopBuhmauR9MMYTJaPY6c1B+XS1q40qFjWukY=; b=CiIePsEurPF139qwU7TK3LvRNzpLglwIPmVOv8CnjpQTSJZmU/PK509SK4INvvUdni CwppUM7iM1GmmJ89Czbl2fUBJM5PhZISdclFGes7RnFJEIrX5Dz9KS+ZupVajJ2BzhtG 02VkSG7Fr5xlHe47XzLuiOCV/V8buoIrebzwYzUorIr+2hSLwb7vtUUq3jFVjRkH2j5a L3uDLiQ94YuFKAButAuAqWcn4am7qDPbaqZpj8FdspEAtIWBtmWoBWL3Buj5mBTWqnLq U1B8pN/5i0JGOFVyqRQfkAG5Lu369mLgzc6LX1mmVuFRsd17aDxXjD7lxWh+WAN2VFsX 3SPA== Received: by 10.152.113.66 with SMTP id iw2mr42766241lab.37.1357128047671; Wed, 02 Jan 2013 04:00:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.55.176 with HTTP; Wed, 2 Jan 2013 04:00:27 -0800 (PST) In-Reply-To: References: From: Peter Maydell Date: Wed, 2 Jan 2013 12:00:27 +0000 Message-ID: To: Samuel Seay X-Gm-Message-State: ALoCoQnEvs5EG7b/O5i75KPaF5o4smsmbpkOch9PxfuzhqUuYN1RzEfV4687Wp+nzNlfc9A1G4Cw X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.215.52 Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH] Change to correct PowerPC on a 64bit host 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 2 January 2013 04:58, Samuel Seay wrote: > Attached is a patch for fixing bug #1052857. My local tests show it working > properly on 32 and 64bit. err |= __put_user(set->sig[0] >> 32, &sc->_unused[3]); This looks OK... @@ -4606,8 +4606,6 @@ static void setup_frame(int sig, struct target_sigaction *ka, /* Create a stack frame for the caller of the handler. */ newsp = frame_addr - SIGNAL_FRAMESIZE; - err |= __put_user(env->gpr[1], (target_ulong *)(uintptr_t) newsp); - if (err) goto sigsegv; ...but this bit doesn't. We need to save the old SP to the stack frame, and your patch just skips this step. You're right that the line in question is broken though; it has two problems: * it's using newsp (a guest address) as an argument to __put_user(), which wants a host address * it's using __put_user() which works on locked addresses, but newsp is below the area we locked with lock_user_struct earlier Another dodgy line in this function: env->gpr[4] = (target_ulong) h2g(sc); Since sc is an offset into the struct returned by lock_user_struct(), if DEBUG_REMAP is defined then we're passing the guest a pointer to memory that is free()d by unlock_user_struct(). This should probably be setting gpr[4] to frame_addr + offsetof(something) instead. -- PMM --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -4584,7 +4584,7 @@ static void setup_frame(int sig, struct target_sigaction *ka, signal = current_exec_domain_sig(sig); - err |= __put_user(h2g(ka->_sa_handler), &sc->handler); + err |= __put_user(ka->_sa_handler, &sc->handler); err |= __put_user(set->sig[0], &sc->oldmask); #if defined(TARGET_PPC64)