From patchwork Thu May 12 07:50:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Borntraeger X-Patchwork-Id: 95267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A6DB71007D5 for ; Thu, 12 May 2011 17:50:38 +1000 (EST) Received: from localhost ([::1]:59104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QKQfJ-0001b2-6y for incoming@patchwork.ozlabs.org; Thu, 12 May 2011 03:50:33 -0400 Received: from eggs.gnu.org ([140.186.70.92]:34395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QKQf9-0001ax-9i for qemu-devel@nongnu.org; Thu, 12 May 2011 03:50:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QKQf8-0007AO-8H for qemu-devel@nongnu.org; Thu, 12 May 2011 03:50:23 -0400 Received: from mtagate4.uk.ibm.com ([194.196.100.164]:57115) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QKQf8-000725-0n for qemu-devel@nongnu.org; Thu, 12 May 2011 03:50:22 -0400 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate4.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p4C7oGfG031845 for ; Thu, 12 May 2011 07:50:16 GMT Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4C7oGEs2342986 for ; Thu, 12 May 2011 08:50:16 +0100 Received: from d06av11.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4C7oFaT026127 for ; Thu, 12 May 2011 01:50:15 -0600 Received: from [9.152.224.62] (dyn-9-152-224-62.boeblingen.de.ibm.com [9.152.224.62]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4C7oFwx026116; Thu, 12 May 2011 01:50:15 -0600 Message-ID: <4DCB9137.70008@de.ibm.com> Date: Thu, 12 May 2011 09:50:15 +0200 From: Christian Borntraeger User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: Alexander Graf References: <4DC9346B.9050309@de.ibm.com> <1AFDA82C-ED1F-44AB-A9F0-B53416E15581@suse.de> In-Reply-To: <1AFDA82C-ED1F-44AB-A9F0-B53416E15581@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 194.196.100.164 Cc: Carsten Otte , "qemu-devel@nongnu.org" Subject: [Qemu-devel] [PatchV2] s390x: fix memory detection for guests > 64GB 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 the s390 memory detection has a 16bit field that specifies the amount of increments. This patch adopts the memory size to always fit into that scheme. This also fixes virtio detection for these guests, since the descriptor page is located after the main memory. Signed-off-by: Christian Borntraeger --- target-s390x/op_helper.c | 8 ++++++-- vl.c | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) Index: b/target-s390x/op_helper.c =================================================================== --- a/target-s390x/op_helper.c +++ b/target-s390x/op_helper.c @@ -2361,6 +2361,7 @@ static void ext_interrupt(CPUState *env, int sclp_service_call(CPUState *env, uint32_t sccb, uint64_t code) { int r = 0; + int shift = 0; #ifdef DEBUG_HELPER printf("sclp(0x%x, 0x%" PRIx64 ")\n", sccb, code); @@ -2375,8 +2376,11 @@ int sclp_service_call(CPUState *env, uin switch(code) { case SCLP_CMDW_READ_SCP_INFO: case SCLP_CMDW_READ_SCP_INFO_FORCED: - stw_phys(sccb + SCP_MEM_CODE, ram_size >> 20); - stb_phys(sccb + SCP_INCREMENT, 1); + while ((ram_size >> (20 + shift)) > 65535) { + shift++; + } + stw_phys(sccb + SCP_MEM_CODE, ram_size >> (20 + shift)); + stb_phys(sccb + SCP_INCREMENT, 1 << shift); stw_phys(sccb + SCP_RESPONSE_CODE, 0x10); if (kvm_enabled()) { Index: b/vl.c =================================================================== --- a/vl.c +++ b/vl.c @@ -2962,6 +2962,17 @@ int main(int argc, char **argv, char **e if (ram_size == 0) ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; + /* s390x ram size detection needs a 16bit multiplier + an increment. So + guests > 64GB can be specified in 2MB steps etc */ + if (strstr(machine->name, "s390")) { + int shift = 0; + + while ((ram_size >> (20 + shift)) > 65535) { + shift++; + } + ram_size = ram_size >> (20 + shift) << (20 + shift); + } + /* init the dynamic translator */ cpu_exec_init_all(tb_size * 1024 * 1024);