@@ -1857,6 +1857,45 @@ static void pc_machine_set_pit(Object *obj, bool value, Error **errp)
1857
1857
pcms -> pit_enabled = value ;
1858
1858
}
1859
1859
1860
+ static void pc_machine_get_max_ram_below_4g (Object * obj , Visitor * v ,
1861
+ const char * name , void * opaque ,
1862
+ Error * * errp )
1863
+ {
1864
+ PCMachineState * pcms = PC_MACHINE (obj );
1865
+ uint64_t value = pcms -> max_ram_below_4g ;
1866
+
1867
+ visit_type_size (v , name , & value , errp );
1868
+ }
1869
+
1870
+ static void pc_machine_set_max_ram_below_4g (Object * obj , Visitor * v ,
1871
+ const char * name , void * opaque ,
1872
+ Error * * errp )
1873
+ {
1874
+ PCMachineState * pcms = PC_MACHINE (obj );
1875
+ Error * error = NULL ;
1876
+ uint64_t value ;
1877
+
1878
+ visit_type_size (v , name , & value , & error );
1879
+ if (error ) {
1880
+ error_propagate (errp , error );
1881
+ return ;
1882
+ }
1883
+ if (value > 4 * GiB ) {
1884
+ error_setg (& error ,
1885
+ "Machine option 'max-ram-below-4g=%" PRIu64
1886
+ "' expects size less than or equal to 4G" , value );
1887
+ error_propagate (errp , error );
1888
+ return ;
1889
+ }
1890
+
1891
+ if (value < 1 * MiB ) {
1892
+ warn_report ("Only %" PRIu64 " bytes of RAM below the 4GiB boundary,"
1893
+ "BIOS may not work with less than 1MiB" , value );
1894
+ }
1895
+
1896
+ pcms -> max_ram_below_4g = value ;
1897
+ }
1898
+
1860
1899
static void pc_machine_initfn (Object * obj )
1861
1900
{
1862
1901
PCMachineState * pcms = PC_MACHINE (obj );
@@ -1866,6 +1905,7 @@ static void pc_machine_initfn(Object *obj)
1866
1905
#else
1867
1906
pcms -> vmport = ON_OFF_AUTO_OFF ;
1868
1907
#endif /* CONFIG_VMPORT */
1908
+ pcms -> max_ram_below_4g = 0 ; /* use default */
1869
1909
/* acpi build is enabled by default if machine supports it */
1870
1910
pcms -> acpi_build_enabled = PC_MACHINE_GET_CLASS (pcms )-> has_acpi_build ;
1871
1911
pcms -> smbus_enabled = true;
@@ -1964,6 +2004,12 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
1964
2004
mc -> numa_mem_supported = true;
1965
2005
mc -> default_ram_id = "pc.ram" ;
1966
2006
2007
+ object_class_property_add (oc , PC_MACHINE_MAX_RAM_BELOW_4G , "size" ,
2008
+ pc_machine_get_max_ram_below_4g , pc_machine_set_max_ram_below_4g ,
2009
+ NULL , NULL );
2010
+ object_class_property_set_description (oc , PC_MACHINE_MAX_RAM_BELOW_4G ,
2011
+ "Maximum ram below the 4G boundary (32bit boundary)" );
2012
+
1967
2013
object_class_property_add (oc , PC_MACHINE_DEVMEM_REGION_SIZE , "int" ,
1968
2014
pc_machine_get_device_memory_region_size , NULL ,
1969
2015
NULL , NULL );
0 commit comments