From patchwork Mon Sep 18 21:57:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 815194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="c1a3rCDt"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xx0HV102Zz9s7m for ; Tue, 19 Sep 2017 07:57:58 +1000 (AEST) Received: from localhost ([::1]:39082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du43A-0002VO-9n for incoming@patchwork.ozlabs.org; Mon, 18 Sep 2017 17:57:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du42q-0002VA-S9 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 17:57:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1du42m-0007qi-OE for qemu-devel@nongnu.org; Mon, 18 Sep 2017 17:57:36 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:37390) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1du42m-0007qV-JZ for qemu-devel@nongnu.org; Mon, 18 Sep 2017 17:57:32 -0400 Received: by mail-qk0-x241.google.com with SMTP id r66so1176452qke.4 for ; Mon, 18 Sep 2017 14:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=F9gcL5Yze76hPXUcuIZs9mgBu8V4wnx2MmShHh+Y4W4=; b=c1a3rCDt+MJmPJnvMyWFZM1nigQPuNcylWrxvBlj3pnuBeqTEj/s31/BMV/qErQHvD aNoK7zpjMUAmV30x1B+Ll9v5iH3CPFVYW5iFuy97h6YbM30m+/eYcNqFqlhhyTOwPJnO CH5BYV76FI0SPDA81Qyt8bAYXtNpXD17zW9VVRFj7Ft+QnsimlxwRGDwnEQkqnZky4Tg 6lGvS9LTRHY8PXRyRrz5UhJ2Tr9mNuP+CpfBbdbgOFf62+J86x9MVtPcYtCl62d67vYc Bp/5a4YY218tOUadyohViNrpBmmt+bcfBqSKSsTbo55kdvWtx1sIb1SBKNg09Y7LdQer f/zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=F9gcL5Yze76hPXUcuIZs9mgBu8V4wnx2MmShHh+Y4W4=; b=tZCkiQc+Di1EMVki4t3p6yBIMKanMvENfx9YWRpWsemzkjYAWd5gL35n+mmmg5bwu2 gDaA62AH+2G7AcQ3I4UkLhF5Cblzux3ePI/eVTAzbwD3m0FSgh8HGVEsiidhEThyQ2iN Wy/rf+V0ooc8u36+1SGuzqgXNebtKOZVujTHAcwPOJKOAJ2DIEVOvdYmApVDyt2o+ctR 0LwZPn9DB6acHfUXPu4stMaexFSyhNXp6i7MG3IXNY/NN2THjgZ/Xlj6Sn+WAoXBhtI/ nkxINIEVzn1q0LL0CCm5D2iJ1LNPa3RFstNmZb/pMTplalUpFWSkVB/U2/jweHTFZh1F iOMA== X-Gm-Message-State: AHPjjUgPkaKM++LCnb7koEiT+WVmbxvceJo6YAuk6Ix3aeTndmDzurwQ 68m1Tp9ZDxiwpQ== X-Google-Smtp-Source: AOwi7QB8tApkhifwgke3h8sh0cEv0JMElFYOxZJijGYp0jM19oaWq8iv0l5Fhl9OSG+iko3yVJpxZA== X-Received: by 10.55.212.129 with SMTP id s1mr22335331qks.63.1505771851918; Mon, 18 Sep 2017 14:57:31 -0700 (PDT) Received: from yoga.offpageads.com ([181.93.89.178]) by smtp.gmail.com with ESMTPSA id u52sm5873113qtb.34.2017.09.18.14.57.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Sep 2017 14:57:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Igor Mammedov , Eduardo Habkost , Paolo Bonzini , Peter Maydell Date: Mon, 18 Sep 2017 18:57:19 -0300 Message-Id: <20170918215719.16415-1-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [RFC PATCH] vl.c: add is_system_on_chip flag to force board default cpu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" add a property to restrict the CPU for SoCs once on machine creation and avoid duplicate code in each board. Signed-off-by: Philippe Mathieu-Daudé --- Based-on: 1505318697-77161-6-git-send-email-imammedo@redhat.com include/hw/boards.h | 3 +++ vl.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index 6b67adaef6..20dc0a0ab9 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -129,6 +129,8 @@ typedef struct { * specifies default CPU_TYPE, which will be used for parsing target * specific features and for creating CPUs if CPU name wasn't provided * explicitly at CLI + * @is_system_on_chip: + * If true, board does not support other CPUs than default_cpu_type. * @minimum_page_bits: * If non-zero, the board promises never to create a CPU with a page size * smaller than this, so QEMU can use a more efficient larger page @@ -182,6 +184,7 @@ struct MachineClass { const char *hw_version; ram_addr_t default_ram_size; const char *default_cpu_type; + bool is_system_on_chip; bool option_rom_has_mr; bool rom_file_has_mr; int minimum_page_bits; diff --git a/vl.c b/vl.c index fb6a700e55..6e59ffa856 100644 --- a/vl.c +++ b/vl.c @@ -4717,10 +4717,21 @@ int main(int argc, char **argv, char **envp) current_machine->cpu_model = cpu_model; + if (machine_class->is_system_on_chip && !machine_class->default_cpu_type) { + error_report("System-on-Chip must have a default CPU type"); + exit(1); + } /* parse features once if machine provides default cpu_type */ if (machine_class->default_cpu_type) { current_machine->cpu_type = machine_class->default_cpu_type; if (cpu_model) { + if (machine_class->is_system_on_chip) { + if (strcmp(cpu_model, machine_class->default_cpu_type) != 0) { + error_report("This board can only be used with CPU %s", + machine_class->default_cpu_type); + exit(1); + } + } current_machine->cpu_type = cpu_parse_cpu_model(machine_class->default_cpu_type, cpu_model); }