I would recommend using tod_get()  which will get you the hw clock if 
there is one or the equivalent if running paravirtualized.  You will 
need to take a look and see if the form it returns for the time is 
sufficient for your needs.

Ken Erickson wrote:
> So, is there any way of getting the current time in a PV domU.  Can you 
> suggest an alternate means of
> generating a pseudo-random 32-bit value?  It was recommended to us (the 
> project team) that the RTC
> was a good way of getting something pseudo-random.
> 
> 
> Thanks
> -ken
> 
> 
> Stuart Maybee wrote:
>>
>> This technique won't work in a PV domU since as I mentioned we don't 
>> allow inb/outb  or access to the real physical hardware.  It would 
>> still work in an HVM domU since in that case there is a simulated real 
>> time clock device.
>>
>> Margot Miller wrote:
>>> Yes, we are using outb()'s. We are using the real time clock to 
>>> generate a
>>> random number to help generate a random number for hostid.
>>>
>>> + static int32_t
>>> + set_soft_hostid(void)
>>> + {
>>> +         struct _buf *file;
>>> +         char tokbuf[MAXNAMELEN];
>>> +         token_t token;
>>> +         int done = 0;
>>> +         int i;
>>> +         u_longlong_t tmp;
>>> +         int32_t hostid = -1;
>>> +         unsigned char reg, *c;
>>> +         struct rtc_t rtc;
>>> +         todinfo_t tod;
>>> + +         /*
>>> +          * If /etc/hostid file not found, we'd like to get a pseudo
>>> +          * random number to use at the hostid.  A nice way to do this
>>> +          * is to read the real time clock, but if it's invalid, we
>>> +          * just punt, and use the value of tenmicrodata, hoping it
>>> +          * is random enough.
>>> +          */
>>> + +         if ((file = kobj_open_file(hostid_file)) == (struct _buf 
>>> *)-1) {
>>> +                 /* hostid file not found */
>>> + +                 /* stolen from todpc_rtcget() and friends */
>>> +                 mutex_enter(&tod_lock);
>>> +                 outb(RTC_ADDR, RTC_D);
>>> +                 reg = inb(RTC_DATA);
>>> +                 if ((reg & RTC_VRT) == 0) {     /* clock invalid */
>>> +                         hostid = (int32_t)tenmicrodata; /* punt */
>>> +                 } else {
>>> +                         for (i = 0, c = (unsigned char *)&rtc;
>>> +                             i < RTC_NREG; i++) {
>>> +                                 outb(RTC_ADDR, i);
>>> +                                 *c++ = inb(RTC_DATA);
>>> +                         }
>>> + +                         tod.tod_year = BCD_TO_BYTE(rtc.rtc_yr);
>>> +                         if (tod.tod_year < 69)
>>> +                                 tod.tod_year += 100;
>>> + +                         tod.tod_month = BCD_TO_BYTE(rtc.rtc_mon);
>>> +                         tod.tod_day = BCD_TO_BYTE(rtc.rtc_dom);
>>> +                         /* day of week < 10; no conversion needed */
>>> +                         tod.tod_dow = rtc.rtc_dow;
>>> +                         tod.tod_hour = BCD_TO_BYTE(rtc.rtc_hr);
>>> +                         tod.tod_min = BCD_TO_BYTE(rtc.rtc_min);
>>> +                         tod.tod_sec = BCD_TO_BYTE(rtc.rtc_sec);
>>> +                         hostid = (int32_t)tod_to_utc(tod);
>>> +                 }
>>> +                 mutex_exit(&tod_lock);
>>> +         } else {
>>> +                 /* hostid file found */
>>>   ...
>>>
>>>
>>>
>>>
>>>
>>> Stuart Maybee wrote:
>>>>
>>>> Solaris currently does not support assigning devices to domU and 
>>>> thus also at this time does not permit domU to perform in/out 
>>>> instructions.
>>>> You crashed because you attempted an out instruction.
>>>> Did your changes include adding i/o instructions to Solaris domU?
>>>> There is an outb in startup_modules() but it is ifdef'd out for an 
>>>> i86xpv build.  Are you sure you attempted to boot an i86xpv kernel 
>>>> in your domU?
>>>>
>>>> Margot H. Miller wrote:
>>>>> We based our Solaris build on build 80 and made some minor kernel 
>>>>> changes for our project
>>>>> and in the install consolidation and wanted to test them with xen 
>>>>> to ensure we didn't break anything.   I installed our modified 
>>>>> build 80 and then tried to install that same iso on a domU.  It 
>>>>> crashed as seen below.  Reproducible.  Then used the build 86 iso 
>>>>> from internal Sun server nana
>>>>> and the domU install is working now.  We are going to resync with 
>>>>> the latest xen changes and rebuild but wanted to know if anything 
>>>>> below jumps out or if anyone has any trouble shooting tips.
>>>>> Thanks,
>>>>> Margot
>>>>>
>>>>> # virt-install
>>>>> What is the name of your virtual machine? dom-1
>>>>>  How much RAM should be allocated (in megabytes)? 500
>>>>>  What would you like to use as the disk (path)? /export/home/dom1.img
>>>>>  How large would you like the disk (/export/home/dom1.img) to be 
>>>>> (in gigabytes)? 10
>>>>>  Would you like to enable graphics support? (yes or no) no
>>>>>  What is the install location? /export/home/solarisdvd.iso
>>>>>  
>>>>>
>>>>> Starting install...
>>>>> Creating storage file...  100% |=========================|  10 
>>>>> GB    00:00     Creating 
>>>>> domain...                                                 0 B 00:20 
>>>>> v3.0.4-1-xvm chgset 'Tue Dec 04 09:56:10 2007 +0000 
>>>>> 13231:11a40bfd0ad8'
>>>>> SunOS Release 5.11 Version psylocke:onnv-hostid:01-25-2008 32-bit
>>>>> Copyright 1983-2007 Sun Microsystems, Inc.  All rights reserved.
>>>>> Use is subject to license terms.
>>>>> DEBUG enabled
>>>>>
>>>>> panic[cpu0]/thread=f502c620: BAD TRAP: type=d (#gp General 
>>>>> protection) rp=f50571d0 addr=f502c620
>>>>>
>>>>> #gp General protection
>>>>> addr=0xf502c620
>>>>> pid=0, pc=0xf4c4b219, sp=0xf4c2e0e1, eflags=0x10086
>>>>> cr0: 80050033<pg,wp,ne,et,mp,pe> cr4: 660<xmme,fxsr,mce,pae>
>>>>> cr2: 0
>>>>>          gs:      1b1  fs: f5050000  es: f5050161  ds: f5050161
>>>>>         edi:        0 esi: f502c620 ebp: f505738c esp: f5057208
>>>>>         ebx: ffffffff edx: f5020070 ecx: f50b0258 eax:        d
>>>>>         trp:        d err:        0 eip: f4c4b219  cs:      159
>>>>>         efl:    10086 usp: f4c2e0e1  ss:       70
>>>>>
>>>>> cpu  address     timestamp type  vc  handler   pc
>>>>>   0 f505b20c 179d4e29b6d8 trap 400      ast cmntrap+183
>>>>>   0 f505b164 179d4e29a188 trap   d      #gp outb+9
>>>>>
>>>>> f505711c unix:die+105 (d, f50571d0, f502c6)
>>>>> f50571bc unix:trap+3b5 (f50571d0, f502c620,)
>>>>> f50571d0 unix:cmntrap+18b (1b1, f5050000, f505)
>>>>> f505738c unix:outb+9 (0, f502c620, f502bd)
>>>>> f50573b8 unix:startup_modules+d7 (f50573e0, f4d9438b,)
>>>>> f50573c0 unix:startup+35 (f4c00010, f50531e8,)
>>>>> f50573e0 genunix:main+5b ()
>>>>>
>>>>> skipping system dump - no dump device configured
>>>>> rebooting...
>>>>>  
>>>>>  
>>>>> This message posted from opensolaris.org
>>>>> _______________________________________________
>>>>> xen-discuss mailing list
>>>>> [email protected]
>>>>
>>>
> 
> 

_______________________________________________
xen-discuss mailing list
[email protected]

Reply via email to